29template <
typename T,
typename =
void>
30constexpr auto canPreDecrement =
false;
35template <
typename T,
typename I,
typename =
void>
36constexpr auto canAddAssign =
false;
38template <
typename T,
typename I>
39constexpr auto canAddAssign<T, I, std::void_t<decltype (std::declval<T>() +=
std::declval<I>())>> =
true;
41template <
typename T,
typename I,
typename =
void>
42constexpr auto canSubAssign =
false;
44template <
typename T,
typename I>
45constexpr auto canSubAssign<T, I, std::void_t<decltype (std::declval<T>() -=
std::declval<I>())>> =
true;
47template <
typename T,
typename I,
typename =
void>
48constexpr auto canAdd =
false;
50template <
typename T,
typename I>
51constexpr auto canAdd<T, I, std::void_t<decltype (std::declval<T>() +
std::declval<I>())>> =
true;
53template <
typename T,
typename I,
typename =
void>
54constexpr auto canSub =
false;
56template <
typename T,
typename I>
57constexpr auto canSub<T, I, std::void_t<decltype (std::declval<T>() -
std::declval<I>())>> =
true;
59template <
typename T,
typename I,
typename =
void>
60constexpr auto canLessThan =
false;
62template <
typename T,
typename I>
63constexpr auto canLessThan<T, I, std::void_t<decltype (std::declval<T>() <
std::declval<I>())>> =
true;
65template <
typename T,
typename I,
typename =
void>
66constexpr auto canLessThanEqual =
false;
68template <
typename T,
typename I>
69constexpr auto canLessThanEqual<T, I, std::void_t<decltype (std::declval<T>() <=
std::declval<I>())>> =
true;
71template <
typename T,
typename I,
typename =
void>
72constexpr auto canGreaterThan =
false;
74template <
typename T,
typename I>
75constexpr auto canGreaterThan<T, I, std::void_t<decltype (std::declval<T>() >
std::declval<I>())>> =
true;
77template <
typename T,
typename I,
typename =
void>
78constexpr auto canGreaterThanEqual =
false;
80template <
typename T,
typename I>
81constexpr auto canGreaterThanEqual<T, I, std::void_t<decltype (std::declval<T>() >=
std::declval<I>())>> =
true;
87 template <
typename Range>
90 template <
typename Range>
108template <
typename Index,
typename Value>
126template <
typename Iter,
typename Index = ptrdiff_t>
139 : iterator (
std::move (iter)), index (ind) {}
142 template <
typename OtherIter,
typename OtherInd>
145 return iterator == other.iterator;
149 template <
typename OtherIter,
typename OtherInd>
161 return { index, *iterator };
183 template <
typename T = Iter, std::enable_if_t<detail::canPreDecrement<T>,
int> = 0>
194 template <
typename T = Iter, std::enable_if_t<detail::canPreDecrement<T>,
int> = 0>
205 template <
typename I, std::enable_if_t<detail::canAddAssign<Iter&, I>,
int> = 0>
209 index +=
static_cast<Index
> (diff);
216 template <
typename I, std::enable_if_t<detail::canSubAssign<Iter&, I>,
int> = 0>
220 index -=
static_cast<Index
> (diff);
229 template <
typename OtherIter,
typename OtherInd, std::enable_if_t<detail::canSub<Iter, OtherIter>,
int> = 0>
232 return iterator - other.iterator;
240 template <
typename I, std::enable_if_t<detail::canAdd<EnumerateIterator, I>,
int> = 0>
243 return *(*
this + diff);
249 template <
typename OtherIter,
typename OtherInd, std::enable_if_t<detail::canLessThan<Iter, OtherIter>,
int> = 0>
252 return iterator < other.iterator;
258 template <
typename OtherIter,
typename OtherInd, std::enable_if_t<detail::canLessThanEqual<Iter, OtherIter>,
int> = 0>
261 return iterator <= other.iterator;
267 template <
typename OtherIter,
typename OtherInd, std::enable_if_t<detail::canGreaterThan<Iter, OtherIter>,
int> = 0>
270 return iterator > other.iterator;
276 template <
typename OtherIter,
typename OtherInd, std::enable_if_t<detail::canGreaterThanEqual<Iter, OtherIter>,
int> = 0>
279 return iterator >= other.iterator;
285 template <
typename I, std::enable_if_t<detail::canAddAssign<EnumerateIterator&, I>,
int> = 0>
294 template <
typename I, std::enable_if_t<detail::canAddAssign<EnumerateIterator&, I>,
int> = 0>
303 template <
typename I, std::enable_if_t<detail::canSubAssign<EnumerateIterator&, I>,
int> = 0>
324template <
typename Begin,
typename End>
332 : b (
std::move (bIn)), e (
std::move (eIn)) {}
335 constexpr auto begin()
const {
return b; }
338 constexpr auto end()
const {
return e; }
352template <
typename Begin,
typename End = Begin>
418template <
typename Range,
typename Index = detail::withAdlSize::AdlSignedSize<Range>>
423 return makeRange (EnumerateIterator {
begin (range), startingValue },
424 EnumerateIterator {
end (range), startingValue });
An iterator that wraps some other iterator, keeping track of the relative position of that iterator b...
constexpr EnumerateIterator(Iter iter, Index ind)
Wraps the provided iterator, and sets the internal count to the provided value.
constexpr EnumerateIterator & operator-=(I diff)
Subtracts an integral value from both the iterator and the index.
constexpr EnumerateIterator & operator++()
Increments the iterator and the index.
constexpr bool operator<(const EnumerateIterator< OtherIter, OtherInd > &other) const
Returns the result of comparing the two wrapped iterators.
constexpr EnumerateIterator()=default
Default constructor.
constexpr EnumerateIterator(Iter iter)
Wraps the provided iterator, and sets the internal count to 0.
constexpr bool operator!=(const EnumerateIterator< OtherIter, OtherInd > &other) const
constexpr friend auto operator-(EnumerateIterator iter, I ind)
Returns the result of subtracting an integral value from this iterator.
constexpr bool operator>(const EnumerateIterator< OtherIter, OtherInd > &other) const
Returns the result of comparing the two wrapped iterators.
constexpr EnumerateIterator & operator--()
Decrements the iterator and the index.
constexpr friend auto operator+(EnumerateIterator iter, I ind)
Returns the result of adding an integral value to this iterator.
constexpr auto operator[](I diff) const
Indexes into this iterator, equivalent to adding an integral value to this iterator and then derefere...
constexpr bool operator<=(const EnumerateIterator< OtherIter, OtherInd > &other) const
Returns the result of comparing the two wrapped iterators.
constexpr EnumerateIterator & operator+=(I diff)
Adds an integral value to both the iterator and the index.
constexpr bool operator==(const EnumerateIterator< OtherIter, OtherInd > &other) const
Two EnumerateIterators are considered equal if the wrapped iterators are equal.
constexpr bool operator>=(const EnumerateIterator< OtherIter, OtherInd > &other) const
Returns the result of comparing the two wrapped iterators.
Wraps a pair of iterators, providing member begin() and end() functions that return those iterators.
constexpr IteratorPair(Begin bIn, End eIn)
Constructs a pair from a begin and end iterator.
constexpr auto end() const
Returns the end iterator.
constexpr auto begin() const
Returns the begin iterator.
A general-purpose range object, that simply represents any linear range with a start and end point.
Represents a shared variant value.
constexpr auto enumerate(Range &&range, Index startingValue={})
Given a range and an optional starting offset, returns an IteratorPair that holds EnumerateIterators ...
RangedDirectoryIterator end(const RangedDirectoryIterator &)
Returns a default-constructed sentinel value.
constexpr auto makeRange(Begin begin, End end)
Given two iterators "begin" and "end", returns an IteratorPair with a member begin() and end() functi...
RangedDirectoryIterator begin(const RangedDirectoryIterator &it)
Returns the iterator that was passed in.
Returned when dereferencing an EnumerateIterator.