summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2015-02-10 21:14:54 (GMT)
committerStephen Kelly <steveire@gmail.com>2015-02-11 21:57:55 (GMT)
commit0c12f1ea0da0a5822a7a69b4ff77b45732c72466 (patch)
treeb8b14709b94a3e3e38d35cc9ed5349e367c0889e /Source
parent27c6f017a1ef7c62f7f0332d624add7e8189f81c (diff)
downloadCMake-0c12f1ea0da0a5822a7a69b4ff77b45732c72466.zip
CMake-0c12f1ea0da0a5822a7a69b4ff77b45732c72466.tar.gz
CMake-0c12f1ea0da0a5822a7a69b4ff77b45732c72466.tar.bz2
cmAlgorithms: Add a range adaptor and API for adjusting a range.
Diffstat (limited to 'Source')
-rw-r--r--Source/cmAlgorithms.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/Source/cmAlgorithms.h b/Source/cmAlgorithms.h
index 6c03f51..ad2b9c1 100644
--- a/Source/cmAlgorithms.h
+++ b/Source/cmAlgorithms.h
@@ -122,6 +122,17 @@ struct Range
const_iterator begin() const { return Begin; }
const_iterator end() const { return End; }
bool empty() const { return std::distance(Begin, End) == 0; }
+ 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;
@@ -135,6 +146,14 @@ ContainerAlgorithms::Range<Iter1> cmRange(Iter1 begin, Iter2 end)
return ContainerAlgorithms::Range<Iter1>(begin, end);
}
+template<typename Range>
+ContainerAlgorithms::Range<typename Range::const_iterator>
+cmRange(Range const& range)
+{
+ return ContainerAlgorithms::Range<typename Range::const_iterator>(
+ range.begin(), range.end());
+}
+
template<typename Container>
void cmDeleteAll(Container const& c)
{