diff options
author | Regina Pfeifer <regina@mailbox.org> | 2019-02-15 20:34:44 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2019-02-21 13:24:25 (GMT) |
commit | 9eb0e73f461f168fb036c304de13d7501edf6d12 (patch) | |
tree | 4e606a1e7892217516616add51b7db914caa3147 /Source/cmAlgorithms.h | |
parent | 7574e16096abe57d44cde4e6380a22d940cde98c (diff) | |
download | CMake-9eb0e73f461f168fb036c304de13d7501edf6d12.zip CMake-9eb0e73f461f168fb036c304de13d7501edf6d12.tar.gz CMake-9eb0e73f461f168fb036c304de13d7501edf6d12.tar.bz2 |
cmRange: Move to dedicated header file
Diffstat (limited to 'Source/cmAlgorithms.h')
-rw-r--r-- | Source/cmAlgorithms.h | 67 |
1 files changed, 2 insertions, 65 deletions
diff --git a/Source/cmAlgorithms.h b/Source/cmAlgorithms.h index 1c4160b..2ff1ed0 100644 --- a/Source/cmAlgorithms.h +++ b/Source/cmAlgorithms.h @@ -5,6 +5,8 @@ #include "cmConfigure.h" // IWYU pragma: keep +#include "cmRange.h" + #include "cm_kwiml.h" #include <algorithm> #include <functional> @@ -156,69 +158,12 @@ private: }; } -template <typename const_iterator_> -struct cmRange -{ - typedef const_iterator_ const_iterator; - typedef typename std::iterator_traits<const_iterator>::value_type value_type; - typedef typename std::iterator_traits<const_iterator>::difference_type - difference_type; - cmRange(const_iterator begin_, const_iterator end_) - : Begin(begin_) - , End(end_) - { - } - const_iterator begin() const { return Begin; } - const_iterator end() const { return End; } - bool empty() const { return std::distance(Begin, End) == 0; } - difference_type size() const { return std::distance(Begin, End); } - - cmRange& advance(KWIML_INT_intptr_t amount) & - { - std::advance(this->Begin, amount); - return *this; - } - cmRange advance(KWIML_INT_intptr_t amount) && - { - std::advance(this->Begin, amount); - return std::move(*this); - } - - cmRange& retreat(KWIML_INT_intptr_t amount) & - { - std::advance(End, -amount); - return *this; - } - - cmRange retreat(KWIML_INT_intptr_t amount) && - { - std::advance(End, -amount); - return std::move(*this); - } - -private: - const_iterator Begin; - const_iterator End; -}; - typedef cmRange<std::vector<std::string>::const_iterator> cmStringRange; class cmListFileBacktrace; typedef cmRange<std::vector<cmListFileBacktrace>::const_iterator> cmBacktraceRange; -template <typename Iter1, typename Iter2> -cmRange<Iter1> cmMakeRange(Iter1 begin, Iter2 end) -{ - return cmRange<Iter1>(begin, end); -} - -template <typename Range> -cmRange<typename Range::const_iterator> cmMakeRange(Range const& range) -{ - return cmRange<typename Range::const_iterator>(range.begin(), range.end()); -} - template <typename Range> void cmDeleteAll(Range const& r) { @@ -334,14 +279,6 @@ typename Range::const_iterator cmFindNot(Range const& r, T const& t) return std::find_if(r.begin(), r.end(), [&t](T const& i) { return i != t; }); } -template <typename Range> -cmRange<typename Range::const_reverse_iterator> cmReverseRange( - Range const& range) -{ - return cmRange<typename Range::const_reverse_iterator>(range.rbegin(), - range.rend()); -} - template <class Iter> std::reverse_iterator<Iter> cmMakeReverseIterator(Iter it) { |