cmAlgorithms: Move Range type out of private namespace.

This commit is contained in:
Stephen Kelly 2015-07-18 10:47:04 +02:00 committed by Brad King
parent 8ea0b81d20
commit 1fe71e2ef0
1 changed files with 36 additions and 36 deletions

View File

@ -122,35 +122,6 @@ struct DefaultDeleter<Range, /* valueTypeIsPair = */ true>
}
};
template<typename const_iterator_>
struct Range
{
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;
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<typename FwdIt>
FwdIt RemoveN(FwdIt i1, FwdIt i2, size_t n)
{
@ -178,17 +149,46 @@ private:
}
template<typename Iter1, typename Iter2>
ContainerAlgorithms::Range<Iter1> cmMakeRange(Iter1 begin, Iter2 end)
template<typename const_iterator_>
struct cmRange
{
return ContainerAlgorithms::Range<Iter1>(begin, end);
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(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<typename Iter1, typename Iter2>
cmRange<Iter1> cmMakeRange(Iter1 begin, Iter2 end)
{
return cmRange<Iter1>(begin, end);
}
template<typename Range>
ContainerAlgorithms::Range<typename Range::const_iterator>
cmRange<typename Range::const_iterator>
cmMakeRange(Range const& range)
{
return ContainerAlgorithms::Range<typename Range::const_iterator>(
return cmRange<typename Range::const_iterator>(
range.begin(), range.end());
}
@ -350,10 +350,10 @@ typename Range::const_iterator cmFindNot(Range const& r, T const& t)
}
template<typename Range>
ContainerAlgorithms::Range<typename Range::const_reverse_iterator>
cmRange<typename Range::const_reverse_iterator>
cmReverseRange(Range const& range)
{
return ContainerAlgorithms::Range<typename Range::const_reverse_iterator>(
return cmRange<typename Range::const_reverse_iterator>(
range.rbegin(), range.rend());
}