summaryrefslogtreecommitdiffstats
path: root/Source/cmAlgorithms.h
diff options
context:
space:
mode:
authorMarc Chevrier <marc.chevrier@gmail.com>2020-04-13 10:11:31 (GMT)
committerMarc Chevrier <marc.chevrier@gmail.com>2020-04-17 08:00:03 (GMT)
commitaacd4e4a90a3afb23d681063d2ecba719f1adab8 (patch)
tree7e1a884cb47519099bd5db178681773f82dad688 /Source/cmAlgorithms.h
parent9a450bcfec5411169007d5ca5f1bd40e6f476ff4 (diff)
downloadCMake-aacd4e4a90a3afb23d681063d2ecba719f1adab8.zip
CMake-aacd4e4a90a3afb23d681063d2ecba719f1adab8.tar.gz
CMake-aacd4e4a90a3afb23d681063d2ecba719f1adab8.tar.bz2
Refactoring: add cm::contains to <cmext/algorithm>
Diffstat (limited to 'Source/cmAlgorithms.h')
-rw-r--r--Source/cmAlgorithms.h42
1 files changed, 3 insertions, 39 deletions
diff --git a/Source/cmAlgorithms.h b/Source/cmAlgorithms.h
index c0ac551..8b0aa5e 100644
--- a/Source/cmAlgorithms.h
+++ b/Source/cmAlgorithms.h
@@ -13,20 +13,12 @@
#include <utility>
#include <vector>
+#include <cmext/algorithm>
+
#include "cm_kwiml.h"
#include "cmRange.h"
-template <std::size_t N>
-struct cmOverloadPriority : cmOverloadPriority<N - 1>
-{
-};
-
-template <>
-struct cmOverloadPriority<0>
-{
-};
-
template <typename FwdIt>
FwdIt cmRotate(FwdIt first, FwdIt middle, FwdIt last)
{
@@ -37,34 +29,6 @@ FwdIt cmRotate(FwdIt first, FwdIt middle, FwdIt last)
return first;
}
-template <typename Range, typename Key>
-auto cmContainsImpl(Range const& range, Key const& key, cmOverloadPriority<2>)
- -> decltype(range.exists(key))
-{
- return range.exists(key);
-}
-
-template <typename Range, typename Key>
-auto cmContainsImpl(Range const& range, Key const& key, cmOverloadPriority<1>)
- -> decltype(range.find(key) != range.end())
-{
- return range.find(key) != range.end();
-}
-
-template <typename Range, typename Key>
-bool cmContainsImpl(Range const& range, Key const& key, cmOverloadPriority<0>)
-{
- using std::begin;
- using std::end;
- return std::find(begin(range), end(range), key) != end(range);
-}
-
-template <typename Range, typename Key>
-bool cmContains(Range const& range, Key const& key)
-{
- return cmContainsImpl(range, key, cmOverloadPriority<2>{});
-}
-
namespace ContainerAlgorithms {
template <typename FwdIt>
@@ -158,7 +122,7 @@ ForwardIterator cmRemoveDuplicates(ForwardIterator first, ForwardIterator last)
ForwardIterator result = first;
while (first != last) {
- if (!cmContains(uniq, first)) {
+ if (!cm::contains(uniq, first)) {
if (result != first) {
*result = std::move(*first);
}