From 4c69ec6f121f303113d2f8a158d2e53b7d93d6b4 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 31 Dec 2014 12:23:50 +0100 Subject: SolarisStudio: Use alternative standard library to build CMake. SolarisStudio ships a very old RogueWave standard library implementation (libCstd) and uses it by default for backward compatibility. The macros defined when building the system libCstd need to be the same as the macros defined when using it for binary compatibility reasons etc. The SolarisStudio compiler driver adds macros such as _RWSTD_NO_MEMBER_TEMPLATES and _RWSTD_NO_CLASS_PARTIAL_SPEC etc. These macros disable certain APIs in the standard library headers. Although the compiler supports the features 'member templates' and 'partial template specialization', the standard library does not provide APIs which rely on those features. This means that std::vector::insert in libCStd does not accept a pair of iterators from a different type of container, because that requires member templates, and reverse_iterator can not be constructed from a reverse_iterator because that requires partial specialization (or at least the _RWSTD_NO_CLASS_PARTIAL_SPEC define) and member templates. This causes many problems while building CMake using SolarisStudio, which have not been well understood until now. The problems are usually attributed to compiler limitations, while actually the problem is in the standard library, as in commit v3.0.0-rc1~99^2~1 (Help: Document non-use of std::set::insert., 2014-01-24) and commit 107dcac3 (Fix compilation with the Oracle / Sun compiler (#15318), 2014-12-12). SolarisStudio 12.3 and earlier also ships a version of stlport which may be used instead of libCstd by specifying -library=stlport4 https://docs.oracle.com/cd/E18659_01/html/821-1383/bkakg.html SolarisStudio 12.4 ships a version of libstdc++ from GCC 4.8.2 which may be used by specifying -std=c++03 or -std=c++11 etc http://docs.oracle.com/cd/E37069_01/html/E37075/bkamw.html#OSSCPgnaof Use these more-capable standard library implementations when building cmake. This will allow more use of 'normal' C++ (such as std::vector::insert), and cause fewer surprises resulting from dashboards using SolarisStudio. Because cmake is not a library linked against by 3rd parties and does not have external dependencies, issues related to mixing code using libCStd and libstdc++ do not apply. --- CompileFlags.cmake | 8 ++++++++ bootstrap | 29 +++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/CompileFlags.cmake b/CompileFlags.cmake index e7beb3f..b6cc783 100644 --- a/CompileFlags.cmake +++ b/CompileFlags.cmake @@ -75,6 +75,14 @@ if(CMAKE_SYSTEM_PROCESSOR MATCHES "^parisc") endif() endif() +if (CMAKE_CXX_COMPILER_ID STREQUAL SunPro) + if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.13) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++03") + else() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -library=stlport4") + endif() +endif() + # use the ansi CXX compile flag for building cmake if (CMAKE_ANSI_CXXFLAGS) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_ANSI_CXXFLAGS}") diff --git a/bootstrap b/bootstrap index fe051e1..3574973 100755 --- a/bootstrap +++ b/bootstrap @@ -1154,6 +1154,35 @@ if [ "x${cmake_cxx_compiler_is_gnu}" != "x1" ]; then cmake_test_flags= fi + +if [ "x${cmake_cxx_compiler_is_gnu}" != "x1" ]; then + # Are we SolarisStudio? + + TMPFILE=`cmake_tmp_file` + echo ' + #if defined(__SUNPRO_CC) + #include + int main() { std::cout << "This is SolarisStudio" << std::endl; return 0;} + #endif + ' > ${TMPFILE}.cxx + cmake_cxx_compiler_is_solarisstudio=0 + if cmake_try_run "${cmake_cxx_compiler}" \ + "${cmake_cxx_flags} " "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then + cmake_cxx_compiler_is_solarisstudio=1 + fi + if [ "x${cmake_cxx_compiler_is_solarisstudio}" = "x1" ]; then + echo "${cmake_cxx_compiler} is SolarisStudio compiler" + else + echo "${cmake_cxx_compiler} is not SolarisStudio compiler" + fi + rm -f "${TMPFILE}.cxx" + + if [ "x${cmake_cxx_compiler_is_solarisstudio}" = "x1" ]; then + cmake_cxx_flags="${cmake_cxx_flags} -library=stlport4" + fi +fi + + # Test for kwsys features KWSYS_NAME_IS_KWSYS=0 KWSYS_BUILD_SHARED=0 -- cgit v0.12 From 2f7ef7e38d7aad93f5d25efb4fd7f61468cf06a2 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 31 Dec 2014 14:55:42 +0100 Subject: Revert "Misc. fixes for the Oracle / Sun compiler." This reverts commit 97b65f8156734db2adc367b27c822a5fe332d740. --- Source/cmComputeLinkDepends.cxx | 5 ++--- Source/cmFindPackageCommand.cxx | 15 ++++++--------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx index a636d23..1fb8f30 100644 --- a/Source/cmComputeLinkDepends.cxx +++ b/Source/cmComputeLinkDepends.cxx @@ -266,10 +266,9 @@ cmComputeLinkDepends::Compute() // Iterate in reverse order so we can keep only the last occurrence // of a shared library. std::set emmitted; - const std::vector& cFLO = this->FinalLinkOrder; for(std::vector::const_reverse_iterator - li = cFLO.rbegin(), - le = cFLO.rend(); + li = this->FinalLinkOrder.rbegin(), + le = this->FinalLinkOrder.rend(); li != le; ++li) { int i = *li; diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx index 8410cda..0130006 100644 --- a/Source/cmFindPackageCommand.cxx +++ b/Source/cmFindPackageCommand.cxx @@ -80,15 +80,12 @@ void cmFindPackageCommand::AppendSearchPathGroups() PathLabel::SystemRegistry); // Create the new path objects - this->LabeledPaths.insert( - std::pair( - PathLabel::UserRegistry, cmSearchPath(this))); - this->LabeledPaths.insert( - std::pair( - PathLabel::Builds, cmSearchPath(this))); - this->LabeledPaths.insert( - std::pair( - PathLabel::SystemRegistry, cmSearchPath(this))); + this->LabeledPaths.insert(std::make_pair(PathLabel::UserRegistry, + cmSearchPath(this))); + this->LabeledPaths.insert(std::make_pair(PathLabel::Builds, + cmSearchPath(this))); + this->LabeledPaths.insert(std::make_pair(PathLabel::SystemRegistry, + cmSearchPath(this))); } //---------------------------------------------------------------------------- -- cgit v0.12 From 238dd2fbab1bd4fb53a25dcd07c1ee41da46d451 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 22 Nov 2014 11:00:45 +0100 Subject: Use insert instead of a loop in some cases. Limit this change to inserting into a vector from a vector. A follow up change can use insert for inserting into a set. --- Source/CTest/cmCTestBuildHandler.cxx | 7 ++---- Source/CTest/cmCTestMultiProcessHandler.cxx | 7 ++---- Source/CTest/cmCTestP4.cxx | 6 +---- Source/CTest/cmCTestSubmitCommand.cxx | 18 ++++----------- Source/cmAddTestCommand.cxx | 6 +---- Source/cmConditionEvaluator.cxx | 10 ++------ Source/cmCustomCommand.cxx | 13 +++-------- Source/cmFindBase.cxx | 6 ++--- Source/cmFunctionCommand.cxx | 6 +---- Source/cmGeneratorTarget.cxx | 6 +---- Source/cmInstallFilesCommand.cxx | 7 ++---- Source/cmInstallProgramsCommand.cxx | 6 +---- Source/cmLocalGenerator.cxx | 12 ++-------- Source/cmLocalUnixMakefileGenerator3.cxx | 9 ++------ Source/cmMacroCommand.cxx | 6 +---- Source/cmMakefile.cxx | 7 +----- Source/cmMakefileTargetGenerator.cxx | 36 ++++++++--------------------- Source/cmQtAutoGenerators.cxx | 31 ++++++------------------- Source/cmRemoveCommand.cxx | 5 +--- Source/cmSystemTools.cxx | 6 +---- Source/cmTarget.cxx | 7 ++---- 21 files changed, 48 insertions(+), 169 deletions(-) diff --git a/Source/CTest/cmCTestBuildHandler.cxx b/Source/CTest/cmCTestBuildHandler.cxx index d226a6c..5e7d764 100644 --- a/Source/CTest/cmCTestBuildHandler.cxx +++ b/Source/CTest/cmCTestBuildHandler.cxx @@ -1094,11 +1094,8 @@ void cmCTestBuildHandler::ProcessBuffer(const char* data, int length, { // Create a contiguous array for the line this->CurrentProcessingLine.clear(); - t_BuildProcessingQueueType::iterator cit; - for ( cit = queue->begin(); cit != it; ++cit ) - { - this->CurrentProcessingLine.push_back(*cit); - } + this->CurrentProcessingLine.insert(this->CurrentProcessingLine.end(), + queue->begin(), queue->end()); this->CurrentProcessingLine.push_back(0); const char* line = &*this->CurrentProcessingLine.begin(); diff --git a/Source/CTest/cmCTestMultiProcessHandler.cxx b/Source/CTest/cmCTestMultiProcessHandler.cxx index 4c89caa..97637ed 100644 --- a/Source/CTest/cmCTestMultiProcessHandler.cxx +++ b/Source/CTest/cmCTestMultiProcessHandler.cxx @@ -526,11 +526,8 @@ void cmCTestMultiProcessHandler::CreateParallelTestCostList() TestList sortedCopy; - for(TestSet::const_iterator j = currentSet.begin(); - j != currentSet.end(); ++j) - { - sortedCopy.push_back(*j); - } + sortedCopy.insert(sortedCopy.end(), + currentSet.begin(), currentSet.end()); std::stable_sort(sortedCopy.begin(), sortedCopy.end(), comp); diff --git a/Source/CTest/cmCTestP4.cxx b/Source/CTest/cmCTestP4.cxx index 0bb1a99..52b98d7 100644 --- a/Source/CTest/cmCTestP4.cxx +++ b/Source/CTest/cmCTestP4.cxx @@ -349,11 +349,7 @@ void cmCTestP4::SetP4Options(std::vector &CommandOptions) std::vector args = cmSystemTools::ParseArguments(opts.c_str()); - for(std::vector::const_iterator ai = args.begin(); - ai != args.end(); ++ai) - { - P4Options.push_back(*ai); - } + P4Options.insert(P4Options.end(), args.begin(), args.end()); } CommandOptions.clear(); diff --git a/Source/CTest/cmCTestSubmitCommand.cxx b/Source/CTest/cmCTestSubmitCommand.cxx index 07a994d..4aa8d04 100644 --- a/Source/CTest/cmCTestSubmitCommand.cxx +++ b/Source/CTest/cmCTestSubmitCommand.cxx @@ -74,13 +74,8 @@ cmCTestGenericHandler* cmCTestSubmitCommand::InitializeHandler() std::vector notesFiles; cmCTest::VectorOfStrings newNotesFiles; cmSystemTools::ExpandListArgument(notesFilesVariable,notesFiles); - std::vector::iterator it; - for ( it = notesFiles.begin(); - it != notesFiles.end(); - ++ it ) - { - newNotesFiles.push_back(*it); - } + newNotesFiles.insert(newNotesFiles.end(), + notesFiles.begin(), notesFiles.end()); this->CTest->GenerateNotesFile(newNotesFiles); } @@ -91,13 +86,8 @@ cmCTestGenericHandler* cmCTestSubmitCommand::InitializeHandler() std::vector extraFiles; cmCTest::VectorOfStrings newExtraFiles; cmSystemTools::ExpandListArgument(extraFilesVariable,extraFiles); - std::vector::iterator it; - for ( it = extraFiles.begin(); - it != extraFiles.end(); - ++ it ) - { - newExtraFiles.push_back(*it); - } + newExtraFiles.insert(newExtraFiles.end(), + extraFiles.begin(), extraFiles.end()); if ( !this->CTest->SubmitExtraFiles(newExtraFiles)) { this->SetError("problem submitting extra files."); diff --git a/Source/cmAddTestCommand.cxx b/Source/cmAddTestCommand.cxx index 2531a1a..dc3b4c2 100644 --- a/Source/cmAddTestCommand.cxx +++ b/Source/cmAddTestCommand.cxx @@ -36,11 +36,7 @@ bool cmAddTestCommand // Collect the command with arguments. std::vector command; - for(std::vector::const_iterator it = args.begin() + 1; - it != args.end(); ++it) - { - command.push_back(*it); - } + command.insert(command.end(), args.begin() + 1, args.end()); // Create the test but add a generator only the first time it is // seen. This preserves behavior from before test generators. diff --git a/Source/cmConditionEvaluator.cxx b/Source/cmConditionEvaluator.cxx index aba26de..7a601e2 100644 --- a/Source/cmConditionEvaluator.cxx +++ b/Source/cmConditionEvaluator.cxx @@ -53,10 +53,7 @@ bool cmConditionEvaluator::IsTrue( cmArgumentList newArgs; // copy to the list structure - for(unsigned int i = 0; i < args.size(); ++i) - { - newArgs.push_back(args[i]); - } + newArgs.insert(newArgs.end(), args.begin(), args.end()); // now loop through the arguments and see if we can reduce any of them // we do this multiple times. Once for each level of precedence @@ -411,10 +408,7 @@ bool cmConditionEvaluator::HandleLevel0(cmArgumentList &newArgs, // copy to the list structure cmArgumentList::iterator argP1 = arg; argP1++; - for(; argP1 != argClose; argP1++) - { - newArgs2.push_back(*argP1); - } + newArgs2.insert(newArgs2.end(), argP1, argClose); newArgs2.pop_back(); // now recursively invoke IsTrue to handle the values inside the // parenthetical expression diff --git a/Source/cmCustomCommand.cxx b/Source/cmCustomCommand.cxx index 2afb029..015825d 100644 --- a/Source/cmCustomCommand.cxx +++ b/Source/cmCustomCommand.cxx @@ -131,21 +131,14 @@ const char* cmCustomCommand::GetComment() const //---------------------------------------------------------------------------- void cmCustomCommand::AppendCommands(const cmCustomCommandLines& commandLines) { - for(cmCustomCommandLines::const_iterator i=commandLines.begin(); - i != commandLines.end(); ++i) - { - this->CommandLines.push_back(*i); - } + this->CommandLines.insert(this->CommandLines.end(), + commandLines.begin(), commandLines.end()); } //---------------------------------------------------------------------------- void cmCustomCommand::AppendDepends(const std::vector& depends) { - for(std::vector::const_iterator i=depends.begin(); - i != depends.end(); ++i) - { - this->Depends.push_back(*i); - } + this->Depends.insert(this->Depends.end(), depends.begin(), depends.end()); } //---------------------------------------------------------------------------- diff --git a/Source/cmFindBase.cxx b/Source/cmFindBase.cxx index beb6dde..013724e 100644 --- a/Source/cmFindBase.cxx +++ b/Source/cmFindBase.cxx @@ -184,10 +184,8 @@ bool cmFindBase::ParseArguments(std::vector const& argsIn) std::vector shortArgs = this->Names; this->Names.clear(); // clear out any values in Names this->Names.push_back(shortArgs[0]); - for(unsigned int j = 1; j < shortArgs.size(); ++j) - { - this->UserGuessArgs.push_back(shortArgs[j]); - } + this->UserGuessArgs.insert(this->UserGuessArgs.end(), + shortArgs.begin() + 1, shortArgs.end()); } this->ExpandPaths(); diff --git a/Source/cmFunctionCommand.cxx b/Source/cmFunctionCommand.cxx index 3580374..488538f 100644 --- a/Source/cmFunctionCommand.cxx +++ b/Source/cmFunctionCommand.cxx @@ -271,11 +271,7 @@ bool cmFunctionCommand // create a function blocker cmFunctionFunctionBlocker *f = new cmFunctionFunctionBlocker(); - for(std::vector::const_iterator j = args.begin(); - j != args.end(); ++j) - { - f->Args.push_back(*j); - } + f->Args.insert(f->Args.end(), args.begin(), args.end()); this->Makefile->AddFunctionBlocker(f); return true; } diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 2b531e2..435452c 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -489,11 +489,7 @@ bool cmGeneratorTarget::IsSystemIncludeDirectory(const std::string& dir, unique.insert(*li); } result.clear(); - for(std::set::iterator li = unique.begin(); - li != unique.end(); ++li) - { - result.push_back(*li); - } + result.insert(result.end(), unique.begin(), unique.end()); IncludeCacheType::value_type entry(config_upper, result); iter = this->SystemIncludesCache.insert(entry).first; diff --git a/Source/cmInstallFilesCommand.cxx b/Source/cmInstallFilesCommand.cxx index f106e1a..a007693 100644 --- a/Source/cmInstallFilesCommand.cxx +++ b/Source/cmInstallFilesCommand.cxx @@ -47,11 +47,8 @@ bool cmInstallFilesCommand else { this->IsFilesForm = false; - std::vector::const_iterator s = args.begin(); - for (++s;s != args.end(); ++s) - { - this->FinalArgs.push_back(*s); - } + this->FinalArgs.insert(this->FinalArgs.end(), + args.begin() + 1, args.end()); } this->Makefile->GetLocalGenerator()->GetGlobalGenerator() diff --git a/Source/cmInstallProgramsCommand.cxx b/Source/cmInstallProgramsCommand.cxx index 0405769..cc223ab 100644 --- a/Source/cmInstallProgramsCommand.cxx +++ b/Source/cmInstallProgramsCommand.cxx @@ -27,11 +27,7 @@ bool cmInstallProgramsCommand this->Destination = args[0]; - std::vector::const_iterator s = args.begin(); - for (++s;s != args.end(); ++s) - { - this->FinalArgs.push_back(*s); - } + this->FinalArgs.insert(this->FinalArgs.end(), args.begin() + 1, args.end()); this->Makefile->GetLocalGenerator()->GetGlobalGenerator() ->AddInstallComponent(this->Makefile->GetSafeDefinition( diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 2de6c93..a4185ad 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -634,11 +634,7 @@ void cmLocalGenerator::AddCustomCommandToCreateObject(const char* ofname, // Parse the string to get the custom command line. cmCustomCommandLine commandLine; std::vector cmd = cmSystemTools::ParseArguments(i->c_str()); - for(std::vector::iterator a = cmd.begin(); - a != cmd.end(); ++a) - { - commandLine.push_back(*a); - } + commandLine.insert(commandLine.end(), cmd.begin(), cmd.end()); // Store this command line. commandLines.push_back(commandLine); @@ -745,11 +741,7 @@ void cmLocalGenerator::AddBuildTargetRule(const std::string& llang, // Parse the string to get the custom command line. cmCustomCommandLine commandLine; std::vector cmd = cmSystemTools::ParseArguments(i->c_str()); - for(std::vector::iterator a = cmd.begin(); - a != cmd.end(); ++a) - { - commandLine.push_back(*a); - } + commandLine.insert(commandLine.end(), cmd.begin(), cmd.end()); // Store this command line. commandLines.push_back(commandLine); diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 812ded3..96beb1c 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -1856,13 +1856,8 @@ void cmLocalUnixMakefileGenerator3 { text = "Running external command ..."; } - std::set::const_iterator dit; - for ( dit = glIt->second.GetUtilities().begin(); - dit != glIt->second.GetUtilities().end(); - ++ dit ) - { - depends.push_back(*dit); - } + depends.insert(depends.end(), glIt->second.GetUtilities().begin(), + glIt->second.GetUtilities().end()); this->AppendEcho(commands, text, cmLocalUnixMakefileGenerator3::EchoGlobal); diff --git a/Source/cmMacroCommand.cxx b/Source/cmMacroCommand.cxx index ae81c58..d399313 100644 --- a/Source/cmMacroCommand.cxx +++ b/Source/cmMacroCommand.cxx @@ -328,11 +328,7 @@ bool cmMacroCommand::InitialPass(std::vector const& args, // create a function blocker cmMacroFunctionBlocker *f = new cmMacroFunctionBlocker(); - for(std::vector::const_iterator j = args.begin(); - j != args.end(); ++j) - { - f->Args.push_back(*j); - } + f->Args.insert(f->Args.end(), args.begin(), args.end()); this->Makefile->AddFunctionBlocker(f); return true; } diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 20dae5a..25d5881 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -2567,12 +2567,7 @@ std::vector cmMakefile } std::vector res; - - std::set::iterator fit; - for ( fit = definitions.begin(); fit != definitions.end(); fit ++ ) - { - res.push_back(*fit); - } + res.insert(res.end(), definitions.begin(), definitions.end()); return res; } diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index cbf8573..040a7d6 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -759,13 +759,10 @@ cmMakefileTargetGenerator if(const char* extra_outputs_str = source.GetProperty("OBJECT_OUTPUTS")) { + // Register these as extra files to clean. cmSystemTools::ExpandListArgument(extra_outputs_str, outputs); - for(std::vector::const_iterator eoi = outputs.begin()+1; - eoi != outputs.end(); ++eoi) - { - // Register this as an extra file to clean. - this->CleanFiles.push_back(*eoi); - } + this->CleanFiles.insert(this->CleanFiles.end(), + outputs.begin() + 1, outputs.end()); } // Write the rule. @@ -1174,11 +1171,7 @@ cmMakefileTargetGenerator { cmCustomCommandGenerator ccg(*cc, this->ConfigName, this->Makefile); const std::vector& outputs = ccg.GetOutputs(); - for(std::vector::const_iterator o = outputs.begin(); - o != outputs.end(); ++o) - { - depends.push_back(*o); - } + depends.insert(depends.end(), outputs.begin(), outputs.end()); } } } @@ -1462,11 +1455,8 @@ void cmMakefileTargetGenerator::WriteTargetDriverRule( } // Make sure the extra files are built. - for(std::set::const_iterator i = this->ExtraFiles.begin(); - i != this->ExtraFiles.end(); ++i) - { - depends.push_back(*i); - } + depends.insert(depends.end(), + this->ExtraFiles.begin(), this->ExtraFiles.end()); } // Write the driver rule. @@ -1553,11 +1543,7 @@ void cmMakefileTargetGenerator if(cmComputeLinkInformation* cli = this->Target->GetLinkInformation(cfg)) { std::vector const& libDeps = cli->GetDepends(); - for(std::vector::const_iterator j = libDeps.begin(); - j != libDeps.end(); ++j) - { - depends.push_back(*j); - } + depends.insert(depends.end(), libDeps.begin(), libDeps.end()); } } @@ -1577,12 +1563,8 @@ void cmMakefileTargetGenerator } // Add dependencies on the external object files. - for(std::vector::const_iterator obj - = this->ExternalObjects.begin(); - obj != this->ExternalObjects.end(); ++obj) - { - depends.push_back(*obj); - } + depends.insert(depends.end(), + this->ExternalObjects.begin(), this->ExternalObjects.end()); // Add a dependency on the rule file itself. this->LocalGenerator->AppendRuleDepend(depends, diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index a01a384..443162a 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -2188,24 +2188,12 @@ bool cmQtAutoGenerators::GenerateMoc(const std::string& sourceFile, std::vector command; command.push_back(this->MocExecutable); - for (std::list::const_iterator it = this->MocIncludes.begin(); - it != this->MocIncludes.end(); - ++it) - { - command.push_back(*it); - } - for(std::list::const_iterator it=this->MocDefinitions.begin(); - it != this->MocDefinitions.end(); - ++it) - { - command.push_back(*it); - } - for(std::vector::const_iterator it=this->MocOptions.begin(); - it != this->MocOptions.end(); - ++it) - { - command.push_back(*it); - } + command.insert(command.end(), + this->MocIncludes.begin(), this->MocIncludes.end()); + command.insert(command.end(), + this->MocDefinitions.begin(), this->MocDefinitions.end()); + command.insert(command.end(), + this->MocOptions.begin(), this->MocOptions.end()); #ifdef _WIN32 command.push_back("-DWIN32"); #endif @@ -2277,12 +2265,7 @@ bool cmQtAutoGenerators::GenerateUi(const std::string& realName, cmSystemTools::ExpandListArgument(optionIt->second, fileOpts); this->MergeUicOptions(opts, fileOpts, this->QtMajorVersion == "5"); } - for(std::vector::const_iterator optIt = opts.begin(); - optIt != opts.end(); - ++optIt) - { - command.push_back(*optIt); - } + command.insert(command.end(), opts.begin(), opts.end()); command.push_back("-o"); command.push_back(this->Builddir + ui_output_file); diff --git a/Source/cmRemoveCommand.cxx b/Source/cmRemoveCommand.cxx index bcb8564..d8aa1cb 100644 --- a/Source/cmRemoveCommand.cxx +++ b/Source/cmRemoveCommand.cxx @@ -39,10 +39,7 @@ bool cmRemoveCommand // check for REMOVE(VAR v1 v2 ... vn) std::vector argsExpanded; std::vector temp; - for(unsigned int j = 1; j < args.size(); ++j) - { - temp.push_back(args[j]); - } + temp.insert(temp.end(), args.begin() + 1, args.end()); cmSystemTools::ExpandList(temp, argsExpanded); // now create the new value diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 1c8c387..54dafd2 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -1273,11 +1273,7 @@ bool cmSystemTools::Split(const char* s, std::vector& l) { std::vector temp; bool res = Superclass::Split(s, temp); - for(std::vector::const_iterator i = temp.begin(); - i != temp.end(); ++i) - { - l.push_back(*i); - } + l.insert(l.end(), temp.begin(), temp.end()); return res; } diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 94a6de3..1b39804 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -6449,11 +6449,8 @@ cmTargetInternals::ComputeLinkImplementationLanguages( // Get languages used in our source files. thisTarget->GetLanguages(languages, config); // Copy the set of langauges to the link implementation. - for(std::set::iterator li = languages.begin(); - li != languages.end(); ++li) - { - impl.Languages.push_back(*li); - } + impl.Languages.insert(impl.Languages.begin(), + languages.begin(), languages.end()); } //---------------------------------------------------------------------------- -- cgit v0.12 From 6162c9194bfb416ac43f52f281db442a4d484aff Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 25 Nov 2014 16:33:00 +0100 Subject: Use two-iterator std::set::insert where appropriate. --- Source/CPack/WiX/cmCPackWIXGenerator.cxx | 7 +------ Source/CTest/cmCTestCoverageHandler.cxx | 6 +----- Source/CTest/cmCTestMultiProcessHandler.cxx | 15 ++++----------- Source/CTest/cmCTestSubmitHandler.cxx | 18 +++--------------- Source/CTest/cmCTestTestHandler.cxx | 6 +----- Source/cmCommandArgumentsHelper.cxx | 9 ++------- Source/cmComputeLinkInformation.cxx | 19 ++++--------------- Source/cmDependsC.cxx | 6 +----- Source/cmDependsFortran.cxx | 10 +++------- Source/cmExportFileGenerator.cxx | 6 +----- Source/cmExtraCodeBlocksGenerator.cxx | 22 ++++------------------ Source/cmGeneratorTarget.cxx | 6 +----- Source/cmGlobalNinjaGenerator.cxx | 9 +++------ Source/cmGlobalVisualStudioGenerator.cxx | 12 ++---------- Source/cmIncludeDirectoryCommand.cxx | 6 +----- Source/cmMakefile.cxx | 18 +++--------------- Source/cmQtAutoGenerators.cxx | 14 ++------------ Source/cmTarget.cxx | 20 ++++---------------- 18 files changed, 41 insertions(+), 168 deletions(-) diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.cxx b/Source/CPack/WiX/cmCPackWIXGenerator.cxx index 7e00027..59c38e9 100644 --- a/Source/CPack/WiX/cmCPackWIXGenerator.cxx +++ b/Source/CPack/WiX/cmCPackWIXGenerator.cxx @@ -1150,12 +1150,7 @@ void cmCPackWIXGenerator::CollectExtensions( std::vector list; cmSystemTools::ExpandListArgument(variableContent, list); - - for(std::vector::const_iterator i = list.begin(); - i != list.end(); ++i) - { - extensions.insert(*i); - } + extensions.insert(list.begin(), list.end()); } void cmCPackWIXGenerator::AddCustomFlags( diff --git a/Source/CTest/cmCTestCoverageHandler.cxx b/Source/CTest/cmCTestCoverageHandler.cxx index a1d770b..fb3e367 100644 --- a/Source/CTest/cmCTestCoverageHandler.cxx +++ b/Source/CTest/cmCTestCoverageHandler.cxx @@ -2498,11 +2498,7 @@ void cmCTestCoverageHandler::LoadLabels(const char* dir) // Label the source with the target labels. LabelSet& labelSet = this->SourceLabels[source]; - for(std::vector::const_iterator li = targetLabels.begin(); - li != targetLabels.end(); ++li) - { - labelSet.insert(*li); - } + labelSet.insert(targetLabels.begin(), targetLabels.end()); } } } diff --git a/Source/CTest/cmCTestMultiProcessHandler.cxx b/Source/CTest/cmCTestMultiProcessHandler.cxx index 97637ed..b83ebe0 100644 --- a/Source/CTest/cmCTestMultiProcessHandler.cxx +++ b/Source/CTest/cmCTestMultiProcessHandler.cxx @@ -162,12 +162,9 @@ void cmCTestMultiProcessHandler::StartTestProcess(int test) //--------------------------------------------------------- void cmCTestMultiProcessHandler::LockResources(int index) { - for(std::set::iterator i = - this->Properties[index]->LockedResources.begin(); - i != this->Properties[index]->LockedResources.end(); ++i) - { - this->LockedResources.insert(*i); - } + this->LockedResources.insert( + this->Properties[index]->LockedResources.begin(), + this->Properties[index]->LockedResources.end()); } //--------------------------------------------------------- @@ -499,11 +496,7 @@ void cmCTestMultiProcessHandler::CreateParallelTestCostList() i != previousSet.end(); ++i) { TestSet const& dependencies = this->Tests[*i]; - for(TestSet::const_iterator j = dependencies.begin(); - j != dependencies.end(); ++j) - { - currentSet.insert(*j); - } + currentSet.insert(dependencies.begin(), dependencies.end()); } for(TestSet::const_iterator i = currentSet.begin(); diff --git a/Source/CTest/cmCTestSubmitHandler.cxx b/Source/CTest/cmCTestSubmitHandler.cxx index 6aa1c2b..fea94ba 100644 --- a/Source/CTest/cmCTestSubmitHandler.cxx +++ b/Source/CTest/cmCTestSubmitHandler.cxx @@ -1160,11 +1160,7 @@ int cmCTestSubmitHandler::ProcessHandler() { // Submit the explicitly selected files: // - cmCTest::SetOfStrings::const_iterator it; - for (it = this->Files.begin(); it != this->Files.end(); ++it) - { - files.insert(*it); - } + files.insert(this->Files.begin(), this->Files.end()); } // Add to the list of files to submit from any selected, existing parts: @@ -1219,11 +1215,7 @@ int cmCTestSubmitHandler::ProcessHandler() // Submit files from this part. std::vector const& pfiles = this->CTest->GetSubmitFiles(p); - for(std::vector::const_iterator pi = pfiles.begin(); - pi != pfiles.end(); ++pi) - { - files.insert(*pi); - } + files.insert(pfiles.begin(), pfiles.end()); } if ( ofs ) @@ -1503,9 +1495,5 @@ void cmCTestSubmitHandler::SelectParts(std::set const& parts) //---------------------------------------------------------------------------- void cmCTestSubmitHandler::SelectFiles(cmCTest::SetOfStrings const& files) { - cmCTest::SetOfStrings::const_iterator it; - for (it = files.begin(); it != files.end(); ++it) - { - this->Files.insert(*it); - } + this->Files.insert(files.begin(), files.end()); } diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index 38ce3dc..0d8d46e 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -2163,11 +2163,7 @@ bool cmCTestTestHandler::SetTestsProperties( std::vector lval; cmSystemTools::ExpandListArgument(val, lval); - for(std::vector::iterator f = lval.begin(); - f != lval.end(); ++f) - { - rtit->LockedResources.insert(*f); - } + rtit->LockedResources.insert(lval.begin(), lval.end()); } if ( key == "TIMEOUT" ) { diff --git a/Source/cmCommandArgumentsHelper.cxx b/Source/cmCommandArgumentsHelper.cxx index 1d5fc07..1a2efc6 100644 --- a/Source/cmCommandArgumentsHelper.cxx +++ b/Source/cmCommandArgumentsHelper.cxx @@ -50,13 +50,8 @@ void cmCommandArgument::FollowsGroup(const cmCommandArgumentGroup* group) if (group!=0) { this->ArgumentsBeforeEmpty = false; - for(std::vector::const_iterator - argIt= group->ContainedArguments.begin(); - argIt != group->ContainedArguments.end(); - ++argIt) - { - this->ArgumentsBefore.insert(*argIt); - } + this->ArgumentsBefore.insert(group->ContainedArguments.begin(), + group->ContainedArguments.end()); } } diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index f4fa5c6..7171d6b 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -408,11 +408,7 @@ cmComputeLinkInformation // Construct a mask to not bother with this behavior for link // directories already specified by the user. std::vector const& dirs = this->Target->GetLinkDirectories(); - for(std::vector::const_iterator di = dirs.begin(); - di != dirs.end(); ++di) - { - this->OldLinkDirMask.insert(*di); - } + this->OldLinkDirMask.insert(dirs.begin(), dirs.end()); } } @@ -1420,11 +1416,8 @@ void cmComputeLinkInformation::ComputeFrameworkInfo() cmSystemTools::ExpandListArgument(implicitDirs, implicitDirVec); } - for(std::vector::const_iterator i = implicitDirVec.begin(); - i != implicitDirVec.end(); ++i) - { - this->FrameworkPathsEmmitted.insert(*i); - } + this->FrameworkPathsEmmitted.insert(implicitDirVec.begin(), + implicitDirVec.end()); // Regular expression to extract a framework path and name. this->SplitFramework.compile("(.*)/(.*)\\.framework$"); @@ -1694,11 +1687,7 @@ void cmComputeLinkInformation::LoadImplicitLinkInfo() } // Store implicit link directories. - for(std::vector::const_iterator i = implicitDirVec.begin(); - i != implicitDirVec.end(); ++i) - { - this->ImplicitLinkDirs.insert(*i); - } + this->ImplicitLinkDirs.insert(implicitDirVec.begin(), implicitDirVec.end()); // Get language-specific implicit libraries. std::vector implicitLibVec; diff --git a/Source/cmDependsC.cxx b/Source/cmDependsC.cxx index a1fc268..a8711eb 100644 --- a/Source/cmDependsC.cxx +++ b/Source/cmDependsC.cxx @@ -125,11 +125,7 @@ bool cmDependsC::WriteDependencies(const std::set& sources, this->ValidDeps->find(obj); if (tmpIt!= this->ValidDeps->end()) { - for(DependencyVector::const_iterator i=tmpIt->second.begin(); - i != tmpIt->second.end(); ++i) - { - dependencies.insert(*i); - } + dependencies.insert(tmpIt->second.begin(), tmpIt->second.end()); haveDeps = true; } } diff --git a/Source/cmDependsFortran.cxx b/Source/cmDependsFortran.cxx index 4082d24..d9818ce 100644 --- a/Source/cmDependsFortran.cxx +++ b/Source/cmDependsFortran.cxx @@ -319,17 +319,13 @@ void cmDependsFortran::LocateModules() infoI != objInfo.end(); ++infoI) { cmDependsFortranSourceInfo const& info = infoI->second; - for(std::set::const_iterator i = info.Provides.begin(); - i != info.Provides.end(); ++i) - { - // Include this module in the set provided by this target. - this->Internal->TargetProvides.insert(*i); - } + // Include this module in the set provided by this target. + this->Internal->TargetProvides.insert(info.Provides.begin(), + info.Provides.end()); for(std::set::const_iterator i = info.Requires.begin(); i != info.Requires.end(); ++i) { - // Include this module in the set required by this target. this->Internal->TargetRequires[*i] = ""; } } diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index 1f39d7a..2b81d60 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -456,11 +456,7 @@ void getPropertyContents(cmTarget const* tgt, const std::string& prop, } std::vector content; cmSystemTools::ExpandListArgument(p, content); - for (std::vector::const_iterator ci = content.begin(); - ci != content.end(); ++ci) - { - ifaceProperties.insert(*ci); - } + ifaceProperties.insert(content.begin(), content.end()); } //---------------------------------------------------------------------------- diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx index 79d7bcaff..69857ef 100644 --- a/Source/cmExtraCodeBlocksGenerator.cxx +++ b/Source/cmExtraCodeBlocksGenerator.cxx @@ -615,12 +615,8 @@ void cmExtraCodeBlocksGenerator::AppendTarget(cmGeneratedFileStream& fout, std::vector includes; target->GetMakefile()->GetLocalGenerator()-> GetIncludeDirectories(includes, gtgt, "C", buildType); - for(std::vector::const_iterator dirIt=includes.begin(); - dirIt != includes.end(); - ++dirIt) - { - uniqIncludeDirs.insert(*dirIt); - } + + uniqIncludeDirs.insert(includes.begin(), includes.end()); std::string systemIncludeDirs = makefile->GetSafeDefinition( "CMAKE_EXTRA_GENERATOR_C_SYSTEM_INCLUDE_DIRS"); @@ -628,12 +624,7 @@ void cmExtraCodeBlocksGenerator::AppendTarget(cmGeneratedFileStream& fout, { std::vector dirs; cmSystemTools::ExpandListArgument(systemIncludeDirs, dirs); - for(std::vector::const_iterator dirIt=dirs.begin(); - dirIt != dirs.end(); - ++dirIt) - { - uniqIncludeDirs.insert(*dirIt); - } + uniqIncludeDirs.insert(dirs.begin(), dirs.end()); } systemIncludeDirs = makefile->GetSafeDefinition( @@ -642,12 +633,7 @@ void cmExtraCodeBlocksGenerator::AppendTarget(cmGeneratedFileStream& fout, { std::vector dirs; cmSystemTools::ExpandListArgument(systemIncludeDirs, dirs); - for(std::vector::const_iterator dirIt=dirs.begin(); - dirIt != dirs.end(); - ++dirIt) - { - uniqIncludeDirs.insert(*dirIt); - } + uniqIncludeDirs.insert(dirs.begin(), dirs.end()); } for(std::set::const_iterator dirIt=uniqIncludeDirs.begin(); diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 435452c..56213e9 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -818,11 +818,7 @@ cmTargetTraceDependencies = ge.Parse(*cli); cge->Evaluate(this->Makefile, "", true); std::set geTargets = cge->GetTargets(); - for(std::set::const_iterator it = geTargets.begin(); - it != geTargets.end(); ++it) - { - targets.insert(*it); - } + targets.insert(geTargets.begin(), geTargets.end()); } } diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 6f0586b..07ea942 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -1021,12 +1021,9 @@ void cmGlobalNinjaGenerator::WriteUnknownExplicitDependencies(std::ostream& os) } //insert outputs from all WirteBuild commands - for(std::set::iterator i = this->CombinedBuildOutputs.begin(); - i != this->CombinedBuildOutputs.end(); ++i) - { - //these paths have already be encoded when added to CombinedBuildOutputs - knownDependencies.insert(*i); - } + //these paths have already be encoded when added to CombinedBuildOutputs + knownDependencies.insert(this->CombinedBuildOutputs.begin(), + this->CombinedBuildOutputs.end()); //after we have combined the data into knownDependencies we have no need //to keep this data around diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index 2dab23c..320a1f4 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -845,22 +845,14 @@ cmGlobalVisualStudioGenerator::TargetCompare cmGlobalVisualStudioGenerator::OrderedTargetDependSet ::OrderedTargetDependSet(TargetDependSet const& targets) { - for(TargetDependSet::const_iterator ti = - targets.begin(); ti != targets.end(); ++ti) - { - this->insert(*ti); - } + this->insert(targets.begin(), targets.end()); } //---------------------------------------------------------------------------- cmGlobalVisualStudioGenerator::OrderedTargetDependSet ::OrderedTargetDependSet(TargetSet const& targets) { - for(TargetSet::const_iterator ti = targets.begin(); - ti != targets.end(); ++ti) - { - this->insert(*ti); - } + this->insert(targets.begin(), targets.end()); } std::string cmGlobalVisualStudioGenerator::ExpandCFGIntDir( diff --git a/Source/cmIncludeDirectoryCommand.cxx b/Source/cmIncludeDirectoryCommand.cxx index df5508e..f37d8bc 100644 --- a/Source/cmIncludeDirectoryCommand.cxx +++ b/Source/cmIncludeDirectoryCommand.cxx @@ -71,11 +71,7 @@ bool cmIncludeDirectoryCommand } if (system) { - for (std::vector::const_iterator li = includes.begin(); - li != includes.end(); ++li) - { - systemIncludes.insert(*li); - } + systemIncludes.insert(includes.begin(), includes.end()); } } std::reverse(beforeIncludes.begin(), beforeIncludes.end()); diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 25d5881..25d23f7 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -1822,11 +1822,7 @@ void cmMakefile::AddIncludeDirectories(const std::vector &incs, void cmMakefile::AddSystemIncludeDirectories(const std::set &incs) { - for(std::set::const_iterator li = incs.begin(); - li != incs.end(); ++li) - { - this->SystemIncludeDirectories.insert(*li); - } + this->SystemIncludeDirectories.insert(incs.begin(), incs.end()); for (cmTargets::iterator l = this->Targets.begin(); l != this->Targets.end(); ++l) @@ -4556,16 +4552,8 @@ void cmMakefile::PopScope() this->Internal->VarInitStack.pop(); this->Internal->VarUsageStack.pop(); // Push initialization and usage up to the parent scope. - it = init.begin(); - for (; it != init.end(); ++it) - { - this->Internal->VarInitStack.top().insert(*it); - } - it = usage.begin(); - for (; it != usage.end(); ++it) - { - this->Internal->VarUsageStack.top().insert(*it); - } + this->Internal->VarInitStack.top().insert(init.begin(), init.end()); + this->Internal->VarUsageStack.top().insert(usage.begin(), usage.end()); } void cmMakefile::RaiseScope(const std::string& var, const char *varDef) diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index 443162a..ded85c3 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -899,12 +899,7 @@ void cmQtAutoGenerators::SetupAutoUicTarget(cmTarget const* target, std::set skipped; std::vector skipVec; cmSystemTools::ExpandListArgument(this->SkipUic, skipVec); - - for (std::vector::const_iterator li = skipVec.begin(); - li != skipVec.end(); ++li) - { - skipped.insert(*li); - } + skipped.insert(skipVec.begin(), skipVec.end()); makefile->AddDefinition("_skip_uic", cmLocalGenerator::EscapeForCMake(this->SkipUic).c_str()); @@ -1622,12 +1617,7 @@ bool cmQtAutoGenerators::RunAutogen(cmMakefile* makefile) std::vector headerFilesVec; cmSystemTools::ExpandListArgument(this->Headers, headerFilesVec); - for (std::vector::const_iterator it = headerFilesVec.begin(); - it != headerFilesVec.end(); - ++it) - { - headerFiles.insert(*it); - } + headerFiles.insert(headerFilesVec.begin(), headerFilesVec.end()); // key = moc source filepath, value = moc output filename std::map notIncludedMocs; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 1b39804..c8fbf61 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -424,12 +424,8 @@ void cmTarget::SetMakefile(cmMakefile* mf) const std::set parentSystemIncludes = this->Makefile->GetSystemIncludeDirectories(); - for (std::set::const_iterator it - = parentSystemIncludes.begin(); - it != parentSystemIncludes.end(); ++it) - { - this->SystemIncludeDirectories.insert(*it); - } + this->SystemIncludeDirectories.insert(parentSystemIncludes.begin(), + parentSystemIncludes.end()); const std::vector parentOptions = this->Makefile->GetCompileOptionsEntries(); @@ -1397,22 +1393,14 @@ void cmTarget::AddLinkLibrary(cmMakefile& mf, void cmTarget::AddSystemIncludeDirectories(const std::set &incs) { - for(std::set::const_iterator li = incs.begin(); - li != incs.end(); ++li) - { - this->SystemIncludeDirectories.insert(*li); - } + this->SystemIncludeDirectories.insert(incs.begin(), incs.end()); } //---------------------------------------------------------------------------- void cmTarget::AddSystemIncludeDirectories(const std::vector &incs) { - for(std::vector::const_iterator li = incs.begin(); - li != incs.end(); ++li) - { - this->SystemIncludeDirectories.insert(*li); - } + this->SystemIncludeDirectories.insert(incs.begin(), incs.end()); } #if defined(_WIN32) && !defined(__CYGWIN__) -- cgit v0.12 From 36b8de563cab1933fb332c42bca68125dd13f35a Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 25 Nov 2014 16:33:00 +0100 Subject: Help: Remove documented restriction on insert APIs. --- Help/manual/cmake-developer.7.rst | 47 --------------------------------------- 1 file changed, 47 deletions(-) diff --git a/Help/manual/cmake-developer.7.rst b/Help/manual/cmake-developer.7.rst index 682ce47..2f98b02 100644 --- a/Help/manual/cmake-developer.7.rst +++ b/Help/manual/cmake-developer.7.rst @@ -54,53 +54,6 @@ Some implementations have a ``std::auto_ptr`` which can not be used as a return value from a function. ``std::auto_ptr`` may not be used. Use ``cmsys::auto_ptr`` instead. -std::vector::insert and std::set --------------------------------- - -Use of ``std::vector::insert`` with an iterator whose ``element_type`` requires -conversion is not allowed: - -.. code-block:: c++ - - std::set theSet; - std::vector theVector; - theVector.insert(theVector.end(), theSet.begin(), theSet.end()); // Wrong - -A loop must be used instead: - -.. code-block:: c++ - - std::set theSet; - std::vector theVector; - for(std::set::iterator li = theSet.begin(); - li != theSet.end(); ++li) - { - theVector.push_back(*li); - } - -std::set::insert ----------------- - -Use of ``std::set::insert`` is not allowed with any source container: - -.. code-block:: c++ - - std::set theSet; - theSet.insert(targets.begin(), targets.end()); // Wrong - -A loop must be used instead: - -.. code-block:: c++ - - ConstIterator it = targets.begin(); - const ConstIterator end = targets.end(); - for ( ; it != end; ++it) - { - theSet.insert(*it); - } - -.. SunCC 5.9 - Template Parameter Defaults --------------------------- -- cgit v0.12 From ac3d38292035a470affdd0ca9df88992916bfeee Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 31 Dec 2014 14:37:44 +0100 Subject: Help: Remove documented restriction on find in conditions. The necessary conversion is supported by all CMake host compilers. --- Help/manual/cmake-developer.7.rst | 26 -------------------------- Source/cmGeneratorExpressionDAGChecker.cxx | 4 +--- 2 files changed, 1 insertion(+), 29 deletions(-) diff --git a/Help/manual/cmake-developer.7.rst b/Help/manual/cmake-developer.7.rst index 2f98b02..a7abb4e 100644 --- a/Help/manual/cmake-developer.7.rst +++ b/Help/manual/cmake-developer.7.rst @@ -21,32 +21,6 @@ CMake is required to build with ancient C++ compilers and standard library implementations. Some common C++ constructs may not be used in CMake in order to build with such toolchains. -std::set const iterators ------------------------- - -The ``find()`` member function of a ``const`` ``std::set`` instance may not be -used in a comparison with the iterator returned by ``end()``: - -.. code-block:: c++ - - const std::set& someSet = getSet(); - if (someSet.find("needle") == someSet.end()) // Wrong - { - // ... - } - -The return value of ``find()`` must be assigned to an intermediate -``const_iterator`` for comparison: - -.. code-block:: c++ - - const std::set& someSet; - const std::set::const_iterator i = someSet.find("needle"); - if (i != propSet.end()) // Ok - { - // ... - } - std::auto_ptr ------------- diff --git a/Source/cmGeneratorExpressionDAGChecker.cxx b/Source/cmGeneratorExpressionDAGChecker.cxx index 75a84cb..a660bd4 100644 --- a/Source/cmGeneratorExpressionDAGChecker.cxx +++ b/Source/cmGeneratorExpressionDAGChecker.cxx @@ -66,9 +66,7 @@ cmGeneratorExpressionDAGChecker::Initialize() if (it != top->Seen.end()) { const std::set &propSet = it->second; - const std::set::const_iterator i - = propSet.find(this->Property); - if (i != propSet.end()) + if (propSet.find(this->Property) != propSet.end()) { this->CheckResult = ALREADY_SEEN; return; -- cgit v0.12 From 5c28495fba56ea488a5a1df323f3c89ff7d28a7e Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 31 Dec 2014 14:38:43 +0100 Subject: Help: Remove documented restriction on template use. --- Help/manual/cmake-developer.7.rst | 6 ------ 1 file changed, 6 deletions(-) diff --git a/Help/manual/cmake-developer.7.rst b/Help/manual/cmake-developer.7.rst index a7abb4e..65b3a72 100644 --- a/Help/manual/cmake-developer.7.rst +++ b/Help/manual/cmake-developer.7.rst @@ -64,12 +64,6 @@ assigning the result of ``.size()`` on a container for example, the result should be assigned to ``size_t`` not to ``std::size_t``, ``unsigned int`` or similar types. -Templates ---------- - -Some template code is permitted, but with some limitations. Member templates -may not be used, and template friends may not be used. - Adding Compile Features ======================= -- cgit v0.12 From 3660d063bc005aa13e7ee4836aef842a91cc87f1 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 1 Jan 2015 13:35:18 +0100 Subject: cmTarget: Use insert instead of std::copy. insert can reserve() memory in the container, and this is more-consistent with the rest of CMake now. --- Source/cmTarget.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index c8fbf61..d454e89 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -6058,8 +6058,8 @@ cmTargetInternals::ComputeLinkInterfaceLibraries( // The link implementation is the default link interface. cmTarget::LinkImplementationLibraries const* impl = thisTarget->GetLinkImplementationLibrariesInternal(config, headTarget); - std::copy(impl->Libraries.begin(), impl->Libraries.end(), - std::back_inserter(iface.Libraries)); + iface.Libraries.insert(iface.Libraries.end(), + impl->Libraries.begin(), impl->Libraries.end()); if(thisTarget->PolicyStatusCMP0022 == cmPolicies::WARN && !this->PolicyWarnedCMP0022 && !usage_requirements_only) { -- cgit v0.12