From 1fe71e2ef04e20ff8e1de888820496fc922bffe0 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 18 Jul 2015 10:47:04 +0200 Subject: [PATCH] cmAlgorithms: Move Range type out of private namespace. --- Source/cmAlgorithms.h | 72 +++++++++++++++++++++---------------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/Source/cmAlgorithms.h b/Source/cmAlgorithms.h index 5013e7425..a4447ad50 100644 --- a/Source/cmAlgorithms.h +++ b/Source/cmAlgorithms.h @@ -122,35 +122,6 @@ struct DefaultDeleter } }; -template -struct Range -{ - typedef const_iterator_ const_iterator; - typedef typename std::iterator_traits::value_type value_type; - typedef typename std::iterator_traits::difference_type - difference_type; - Range(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); } - Range& advance(cmIML_INT_intptr_t amount) - { - std::advance(Begin, amount); - return *this; - } - - Range& retreat(cmIML_INT_intptr_t amount) - { - std::advance(End, -amount); - return *this; - } -private: - const_iterator Begin; - const_iterator End; -}; - template FwdIt RemoveN(FwdIt i1, FwdIt i2, size_t n) { @@ -178,17 +149,46 @@ private: } -template -ContainerAlgorithms::Range cmMakeRange(Iter1 begin, Iter2 end) +template +struct cmRange { - return ContainerAlgorithms::Range(begin, end); + typedef const_iterator_ const_iterator; + typedef typename std::iterator_traits::value_type value_type; + typedef typename std::iterator_traits::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(cmIML_INT_intptr_t amount) + { + std::advance(Begin, amount); + return *this; + } + + cmRange& retreat(cmIML_INT_intptr_t amount) + { + std::advance(End, -amount); + return *this; + } +private: + const_iterator Begin; + const_iterator End; +}; + +template +cmRange cmMakeRange(Iter1 begin, Iter2 end) +{ + return cmRange(begin, end); } template -ContainerAlgorithms::Range +cmRange cmMakeRange(Range const& range) { - return ContainerAlgorithms::Range( + return cmRange( range.begin(), range.end()); } @@ -350,10 +350,10 @@ typename Range::const_iterator cmFindNot(Range const& r, T const& t) } template -ContainerAlgorithms::Range +cmRange cmReverseRange(Range const& range) { - return ContainerAlgorithms::Range( + return cmRange( range.rbegin(), range.rend()); }