summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2020-01-13 15:30:57 (GMT)
committerKitware Robot <kwrobot@kitware.com>2020-01-13 15:31:05 (GMT)
commit95e3c8b440a40a6ed5d61e19c3a9a67989f62dcc (patch)
tree033c1bf8de3207dc2d26c7b1044482a909aad2a1 /Source
parent9a5d399725cbb7012ca7b1f77bd405090c60691d (diff)
parent968477517edb030cee7f9160286b31d4cda4a516 (diff)
downloadCMake-95e3c8b440a40a6ed5d61e19c3a9a67989f62dcc.zip
CMake-95e3c8b440a40a6ed5d61e19c3a9a67989f62dcc.tar.gz
CMake-95e3c8b440a40a6ed5d61e19c3a9a67989f62dcc.tar.bz2
Merge topic 'refactoring-STL-erase_if'
968477517e Refactoring: suppress cmEraseIf in favor of cm::erase_if 348b60d19d STL support: add c++20 std::erase and std::erase_if functions Acked-by: Kitware Robot <kwrobot@kitware.com> Rejected-by: Leonid Pospelov <pospelovlm@yandex.ru> Merge-request: !4192
Diffstat (limited to 'Source')
-rw-r--r--Source/CTest/cmCTestSubmitCommand.cxx5
-rw-r--r--Source/CTest/cmCTestUploadCommand.cxx6
-rw-r--r--Source/cmAlgorithms.h6
-rw-r--r--Source/cmGlobalVisualStudio14Generator.cxx7
-rw-r--r--Source/cmLocalUnixMakefileGenerator3.cxx4
-rw-r--r--Source/cmMakefile.cxx5
-rw-r--r--Source/cmNinjaNormalTargetGenerator.cxx6
7 files changed, 18 insertions, 21 deletions
diff --git a/Source/CTest/cmCTestSubmitCommand.cxx b/Source/CTest/cmCTestSubmitCommand.cxx
index 46b00b1..acb75b2 100644
--- a/Source/CTest/cmCTestSubmitCommand.cxx
+++ b/Source/CTest/cmCTestSubmitCommand.cxx
@@ -7,6 +7,7 @@
#include <utility>
#include <cm/memory>
+#include <cm/vector>
#include "cm_static_string_view.hxx"
@@ -174,7 +175,7 @@ void cmCTestSubmitCommand::CheckArguments(
this->PartsMentioned = !this->Parts.empty() || cmContains(keywords, "PARTS");
this->FilesMentioned = !this->Files.empty() || cmContains(keywords, "FILES");
- cmEraseIf(this->Parts, [this](std::string const& arg) -> bool {
+ cm::erase_if(this->Parts, [this](std::string const& arg) -> bool {
cmCTest::Part p = this->CTest->GetPartFromName(arg.c_str());
if (p == cmCTest::PartCount) {
std::ostringstream e;
@@ -185,7 +186,7 @@ void cmCTestSubmitCommand::CheckArguments(
return false;
});
- cmEraseIf(this->Files, [this](std::string const& arg) -> bool {
+ cm::erase_if(this->Files, [this](std::string const& arg) -> bool {
if (!cmSystemTools::FileExists(arg)) {
std::ostringstream e;
e << "File \"" << arg << "\" does not exist. Cannot submit "
diff --git a/Source/CTest/cmCTestUploadCommand.cxx b/Source/CTest/cmCTestUploadCommand.cxx
index d0e3848..eaef1ca 100644
--- a/Source/CTest/cmCTestUploadCommand.cxx
+++ b/Source/CTest/cmCTestUploadCommand.cxx
@@ -4,11 +4,11 @@
#include <set>
#include <sstream>
-#include <vector>
+
+#include <cm/vector>
#include "cm_static_string_view.hxx"
-#include "cmAlgorithms.h"
#include "cmCTest.h"
#include "cmCTestUploadHandler.h"
#include "cmMakefile.h"
@@ -24,7 +24,7 @@ void cmCTestUploadCommand::BindArguments()
void cmCTestUploadCommand::CheckArguments(std::vector<std::string> const&)
{
- cmEraseIf(this->Files, [this](std::string const& arg) -> bool {
+ cm::erase_if(this->Files, [this](std::string const& arg) -> bool {
if (!cmSystemTools::FileExists(arg)) {
std::ostringstream e;
e << "File \"" << arg << "\" does not exist. Cannot submit "
diff --git a/Source/cmAlgorithms.h b/Source/cmAlgorithms.h
index a179acb..3b0a223 100644
--- a/Source/cmAlgorithms.h
+++ b/Source/cmAlgorithms.h
@@ -37,12 +37,6 @@ 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());
-}
-
template <typename Range, typename Key>
auto cmContainsImpl(Range const& range, Key const& key, cmOverloadPriority<2>)
-> decltype(range.exists(key))
diff --git a/Source/cmGlobalVisualStudio14Generator.cxx b/Source/cmGlobalVisualStudio14Generator.cxx
index 779753e..f549b6a 100644
--- a/Source/cmGlobalVisualStudio14Generator.cxx
+++ b/Source/cmGlobalVisualStudio14Generator.cxx
@@ -2,7 +2,8 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmGlobalVisualStudio14Generator.h"
-#include "cmAlgorithms.h"
+#include <cm/vector>
+
#include "cmDocumentationEntry.h"
#include "cmLocalVisualStudio10Generator.h"
#include "cmMakefile.h"
@@ -303,7 +304,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.
- cmEraseIf(sdks, NoWindowsH());
+ cm::erase_if(sdks, NoWindowsH());
// Only use the filename, which will be the SDK version.
for (std::string& i : sdks) {
@@ -313,7 +314,7 @@ std::string cmGlobalVisualStudio14Generator::GetWindows10SDKVersion()
// Skip SDKs that cannot be used with our toolset.
std::string maxVersion = this->GetWindows10SDKMaxVersion();
if (!maxVersion.empty()) {
- cmEraseIf(sdks, WindowsSDKTooRecent(maxVersion));
+ cm::erase_if(sdks, WindowsSDKTooRecent(maxVersion));
}
// Sort the results to make sure we select the most recent one.
diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx
index f6a0e34..dbdde48 100644
--- a/Source/cmLocalUnixMakefileGenerator3.cxx
+++ b/Source/cmLocalUnixMakefileGenerator3.cxx
@@ -9,12 +9,12 @@
#include <utility>
#include <cm/memory>
+#include <cm/vector>
#include <cmext/algorithm>
#include "cmsys/FStream.hxx"
#include "cmsys/Terminal.h"
-#include "cmAlgorithms.h"
#include "cmCustomCommand.h" // IWYU pragma: keep
#include "cmCustomCommandGenerator.h"
#include "cmFileTimeCache.h"
@@ -1876,7 +1876,7 @@ void cmLocalUnixMakefileGenerator3::WriteDependLanguageInfo(
std::string binaryDir = this->GetState()->GetBinaryDirectory();
if (this->Makefile->IsOn("CMAKE_DEPENDS_IN_PROJECT_ONLY")) {
std::string const& sourceDir = this->GetState()->GetSourceDirectory();
- cmEraseIf(includes, ::NotInProjectDir(sourceDir, binaryDir));
+ cm::erase_if(includes, ::NotInProjectDir(sourceDir, binaryDir));
}
for (std::string const& include : includes) {
cmakefileStream << " \""
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 79cf5a1..7435e47 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -17,6 +17,7 @@
#include <cm/iterator>
#include <cm/memory>
#include <cm/optional>
+#include <cm/vector>
#include <cmext/algorithm>
#include "cmsys/FStream.hxx"
@@ -840,12 +841,12 @@ void cmMakefile::DoGenerate(cmLocalGenerator& lg)
// 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
- cmEraseIf(this->OutputFiles, file_not_persistent());
+ cm::erase_if(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
- cmEraseIf(this->ListFiles, file_not_persistent());
+ cm::erase_if(this->ListFiles, file_not_persistent());
}
// Generate the output file
diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx
index 987f241..360ef3c 100644
--- a/Source/cmNinjaNormalTargetGenerator.cxx
+++ b/Source/cmNinjaNormalTargetGenerator.cxx
@@ -11,8 +11,8 @@
#include <utility>
#include <cm/memory>
+#include <cm/vector>
-#include "cmAlgorithms.h"
#include "cmComputeLinkInformation.h"
#include "cmCustomCommand.h" // IWYU pragma: keep
#include "cmCustomCommandGenerator.h"
@@ -243,7 +243,7 @@ void cmNinjaNormalTargetGenerator::WriteDeviceLinkRule(
}
// If there is no ranlib the command will be ":". Skip it.
- cmEraseIf(linkCmds, cmNinjaRemoveNoOpCommands());
+ cm::erase_if(linkCmds, cmNinjaRemoveNoOpCommands());
rule.Command = this->GetLocalGenerator()->BuildCommandLine(linkCmds);
@@ -379,7 +379,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkRule(bool useResponseFile,
}
// If there is no ranlib the command will be ":". Skip it.
- cmEraseIf(linkCmds, cmNinjaRemoveNoOpCommands());
+ cm::erase_if(linkCmds, cmNinjaRemoveNoOpCommands());
linkCmds.insert(linkCmds.begin(), "$PRE_LINK");
linkCmds.emplace_back("$POST_BUILD");