Go to the documentation of this file.
15 #ifndef BELUGA_UTILITY_INDEXING_ITERATOR_HPP
16 #define BELUGA_UTILITY_INDEXING_ITERATOR_HPP
20 #include <type_traits>
37 template <
class Indexable,
class Index =
typename Indexable::
size_type>
42 std::remove_cv_t<std::remove_reference_t<decltype(std::declval<Indexable>()[std::declval<Index>()])>>;
44 using reference = decltype(std::declval<Indexable>()[std::declval<Index>()]);
46 using pointer = decltype(std::addressof(std::declval<Indexable>()[std::declval<Index>()]));
48 using difference_type = std::make_signed_t<decltype(std::declval<Index>() - std::declval<Index>())>;
93 cursor_ -=
static_cast<raw_difference_type
>(-offset);
95 cursor_ +=
static_cast<raw_difference_type
>(offset);
109 return iterator + offset;
116 cursor_ +=
static_cast<raw_difference_type
>(-offset);
118 cursor_ -=
static_cast<raw_difference_type
>(offset);
IndexingIterator operator+(difference_type offset) const noexcept
Forwards iterator position a given offset, yielding a modified copy.
reference operator*() const noexcept
Dereferences iterator at its current position.
bool operator<(const IndexingIterator &other) const noexcept
Checks if iterator position is strictly before that of another.
bool operator<=(const IndexingIterator &other) const noexcept
Checks if iterator position is before or equal to that of another.
IndexingIterator()=default
Default constructor. Iterator will point nowhere.
IndexingIterator(Indexable *indexable, Index cursor=Index{})
Constructs iterator given a pointer to an indexable container and a cursor index on it.
IndexingIterator(Indexable &indexable, Index cursor=Index{})
Constructs iterator given a reference to an indexable container and a cursor index on it.
IndexingIterator operator--(int) noexcept
Post-decrements iterator position in the target container.
decltype(std::declval< Indexable >()[std::declval< Index >()]) reference
Value reference type of the iterator.
A random access iterator for any indexable container.
pointer operator->() const noexcept
Dereferences iterator at its current position and yields a pointer to it.
IndexingIterator & operator+=(difference_type offset) noexcept
Forwards iterator position a given offset, in-place.
IndexingIterator & operator++() noexcept
Pre-increments iterator position in the target container.
reference operator[](difference_type offset) const noexcept
Dereferences iterator at a given offset from its current position.
IndexingIterator & operator--() noexcept
Pre-decrements iterator position in the target container.
IndexingIterator & operator-=(difference_type offset) noexcept
Rewinds iterator position a given offset, in-place.
bool operator==(const IndexingIterator &other) const noexcept
Checks if iterator position is equal to that of another.
difference_type operator-(const IndexingIterator &other) const noexcept
Computes the difference (i.e. the distance) between the positions of this iterator and another.
std::remove_cv_t< std::remove_reference_t< decltype(std::declval< Indexable >()[std::declval< Index >()])> > value_type
Value type of the iterator.
std::random_access_iterator_tag iterator_category
Category of the iterator.
IndexingIterator operator++(int) noexcept
Post-increments iterator position in the target container.
decltype(std::addressof(std::declval< Indexable >()[std::declval< Index >()])) pointer
Value pointer type of the iterator.
friend IndexingIterator operator+(difference_type offset, const IndexingIterator &iterator)
Forwards iterator a given offset, yielding a modified copy.
bool operator>(const IndexingIterator &other) const noexcept
Checks if iterator position is strictly after that of another.
IndexingIterator operator-(difference_type offset) const noexcept
Rewinds iterator position a given offset, yielding a modified copy.
std::make_signed_t< decltype(std::declval< Index >() - std::declval< Index >())> difference_type
Signed difference type of the iterator.
bool operator>=(const IndexingIterator &other) const noexcept
Checks if iterator position is after or equal to that of another.
bool operator!=(const IndexingIterator &other) const noexcept
Checks if iterator position is not equal to that of another.
The main Beluga namespace.
beluga
Author(s):
autogenerated on Tue Jul 16 2024 02:59:53