summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Pfeifer <daniel@pfeifer-mail.de>2017-02-10 22:04:32 (GMT)
committerDaniel Pfeifer <daniel@pfeifer-mail.de>2017-02-10 22:04:32 (GMT)
commitc3800e54583208ac4a6435884bb8832e72af3183 (patch)
tree12e2b0c67f170e1521cb013b79becc0c419e1a5a
parentee3295e91740033ebe9d9a0c800c0a3070108624 (diff)
downloadCMake-c3800e54583208ac4a6435884bb8832e72af3183.zip
CMake-c3800e54583208ac4a6435884bb8832e72af3183.tar.gz
CMake-c3800e54583208ac4a6435884bb8832e72af3183.tar.bz2
cmAlgorithms: add cmEraseIf function
-rw-r--r--Source/cmAlgorithms.h6
-rw-r--r--Source/cmGlobalVisualStudio14Generator.cxx3
-rw-r--r--Source/cmLocalUnixMakefileGenerator3.cxx5
-rw-r--r--Source/cmMakefile.cxx13
-rw-r--r--Source/cmNinjaNormalTargetGenerator.cxx18
5 files changed, 16 insertions, 29 deletions
diff --git a/Source/cmAlgorithms.h b/Source/cmAlgorithms.h
index 7c683ad..f5469e5 100644
--- a/Source/cmAlgorithms.h
+++ b/Source/cmAlgorithms.h
@@ -101,6 +101,12 @@ FwdIt cmRotate(FwdIt first, FwdIt middle, FwdIt last)
return first;
}
+template <typename Container, typename Predicate>
+void cmEraseIf(Container& cont, Predicate pred)
+{
+ cont.erase(std::remove_if(cont.begin(), cont.end(), pred), cont.end());
+}
+
namespace ContainerAlgorithms {
template <typename T>
diff --git a/Source/cmGlobalVisualStudio14Generator.cxx b/Source/cmGlobalVisualStudio14Generator.cxx
index 81c305c..d2ac36b 100644
--- a/Source/cmGlobalVisualStudio14Generator.cxx
+++ b/Source/cmGlobalVisualStudio14Generator.cxx
@@ -238,8 +238,7 @@ std::string cmGlobalVisualStudio14Generator::GetWindows10SDKVersion()
// Skip SDKs that do not contain <um/windows.h> because that indicates that
// only the UCRT MSIs were installed for them.
- sdks.erase(std::remove_if(sdks.begin(), sdks.end(), NoWindowsH()),
- sdks.end());
+ cmEraseIf(sdks, NoWindowsH());
if (!sdks.empty()) {
// Only use the filename, which will be the SDK version.
diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx
index 41a4caf..4388e75 100644
--- a/Source/cmLocalUnixMakefileGenerator3.cxx
+++ b/Source/cmLocalUnixMakefileGenerator3.cxx
@@ -1864,10 +1864,7 @@ void cmLocalUnixMakefileGenerator3::WriteDependLanguageInfo(
std::string binaryDir = this->GetState()->GetBinaryDirectory();
if (this->Makefile->IsOn("CMAKE_DEPENDS_IN_PROJECT_ONLY")) {
const char* sourceDir = this->GetState()->GetSourceDirectory();
- std::vector<std::string>::iterator itr =
- std::remove_if(includes.begin(), includes.end(),
- ::NotInProjectDir(sourceDir, binaryDir));
- includes.erase(itr, includes.end());
+ cmEraseIf(includes, ::NotInProjectDir(sourceDir, binaryDir));
}
for (std::vector<std::string>::iterator i = includes.begin();
i != includes.end(); ++i) {
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index bfe46ae..618f694 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -653,21 +653,12 @@ void cmMakefile::FinalPass()
// we don't want cmake to re-run if a configured file is created and deleted
// during processing as that would make it a transient file that can't
// influence the build process
-
- // remove_if will move all items that don't have a valid file name to the
- // back of the vector
- std::vector<std::string>::iterator new_output_files_end = std::remove_if(
- this->OutputFiles.begin(), this->OutputFiles.end(), file_not_persistent());
- // we just have to erase all items at the back
- this->OutputFiles.erase(new_output_files_end, this->OutputFiles.end());
+ cmEraseIf(this->OutputFiles, file_not_persistent());
// if a configured file is used as input for another configured file,
// and then deleted it will show up in the input list files so we
// need to scan those too
- std::vector<std::string>::iterator new_list_files_end = std::remove_if(
- this->ListFiles.begin(), this->ListFiles.end(), file_not_persistent());
-
- this->ListFiles.erase(new_list_files_end, this->ListFiles.end());
+ cmEraseIf(this->ListFiles, file_not_persistent());
}
// Generate the output file
diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx
index b172478..9bf0ccd 100644
--- a/Source/cmNinjaNormalTargetGenerator.cxx
+++ b/Source/cmNinjaNormalTargetGenerator.cxx
@@ -260,12 +260,9 @@ void cmNinjaNormalTargetGenerator::WriteDeviceLinkRule(bool useResponseFile)
rulePlaceholderExpander->ExpandRuleVariables(this->GetLocalGenerator(),
*i, vars);
}
- {
- // If there is no ranlib the command will be ":". Skip it.
- std::vector<std::string>::iterator newEnd = std::remove_if(
- linkCmds.begin(), linkCmds.end(), cmNinjaRemoveNoOpCommands());
- linkCmds.erase(newEnd, linkCmds.end());
- }
+
+ // If there is no ranlib the command will be ":". Skip it.
+ cmEraseIf(linkCmds, cmNinjaRemoveNoOpCommands());
std::string linkCmd =
this->GetLocalGenerator()->BuildCommandLine(linkCmds);
@@ -388,12 +385,9 @@ void cmNinjaNormalTargetGenerator::WriteLinkRule(bool useResponseFile)
rulePlaceholderExpander->ExpandRuleVariables(this->GetLocalGenerator(),
*i, vars);
}
- {
- // If there is no ranlib the command will be ":". Skip it.
- std::vector<std::string>::iterator newEnd = std::remove_if(
- linkCmds.begin(), linkCmds.end(), cmNinjaRemoveNoOpCommands());
- linkCmds.erase(newEnd, linkCmds.end());
- }
+
+ // If there is no ranlib the command will be ":". Skip it.
+ cmEraseIf(linkCmds, cmNinjaRemoveNoOpCommands());
linkCmds.insert(linkCmds.begin(), "$PRE_LINK");
linkCmds.push_back("$POST_BUILD");