29template <
typename T,
typename =
void>
30constexpr auto canPreDecrement =
false;
33constexpr auto canPreDecrement<T,
std::void_t<
decltype (--std::declval<T>())>> =
true;
35template <
typename T,
typename I,
typename =
void>
36constexpr auto canAddAssign =
false;
38template <
typename T,
typename I>
41template <
typename T,
typename I,
typename =
void>
42constexpr auto canSubAssign =
false;
44template <
typename T,
typename I>
47template <
typename T,
typename I,
typename =
void>
48constexpr auto canAdd =
false;
50template <
typename T,
typename I>
53template <
typename T,
typename I,
typename =
void>
54constexpr auto canSub =
false;
56template <
typename T,
typename I>
59template <
typename T,
typename I,
typename =
void>
60constexpr auto canLessThan =
false;
62template <
typename T,
typename I>
65template <
typename T,
typename I,
typename =
void>
66constexpr auto canLessThanEqual =
false;
68template <
typename T,
typename I>
71template <
typename T,
typename I,
typename =
void>
72constexpr auto canGreaterThan =
false;
74template <
typename T,
typename I>
77template <
typename T,
typename I,
typename =
void>
78constexpr auto canGreaterThanEqual =
false;
80template <
typename T,
typename I>
87 template <
typename Range>
88 using AdlSize =
decltype (
size (std::declval<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>
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>>
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...
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...
RangedDirectoryIterator begin(const RangedDirectoryIterator &it)
Returns the iterator that was passed in.
Returned when dereferencing an EnumerateIterator.