A random access iterator for any indexable container. More...
#include <indexing_iterator.hpp>
Public Types | |
using | difference_type = std::make_signed_t< decltype(std::declval< Index >() - std::declval< Index >())> |
Signed difference type of the iterator. More... | |
using | iterator_category = std::random_access_iterator_tag |
Category of the iterator. More... | |
using | pointer = decltype(std::addressof(std::declval< Indexable >()[std::declval< Index >()])) |
Value pointer type of the iterator. More... | |
using | reference = decltype(std::declval< Indexable >()[std::declval< Index >()]) |
Value reference type of the iterator. More... | |
using | value_type = std::remove_cv_t< std::remove_reference_t< decltype(std::declval< Indexable >()[std::declval< Index >()])> > |
Value type of the iterator. More... | |
Public Member Functions | |
IndexingIterator ()=default | |
Default constructor. Iterator will point nowhere. More... | |
IndexingIterator (Indexable &indexable, Index cursor=Index{}) | |
Constructs iterator given a reference to an indexable container and a cursor index on it. More... | |
IndexingIterator (Indexable *indexable, Index cursor=Index{}) | |
Constructs iterator given a pointer to an indexable container and a cursor index on it. More... | |
bool | operator!= (const IndexingIterator &other) const noexcept |
Checks if iterator position is not equal to that of another. More... | |
reference | operator* () const noexcept |
Dereferences iterator at its current position. More... | |
IndexingIterator | operator+ (difference_type offset) const noexcept |
Forwards iterator position a given offset , yielding a modified copy. More... | |
IndexingIterator & | operator++ () noexcept |
Pre-increments iterator position in the target container. More... | |
IndexingIterator | operator++ (int) noexcept |
Post-increments iterator position in the target container. More... | |
IndexingIterator & | operator+= (difference_type offset) noexcept |
Forwards iterator position a given offset , in-place. More... | |
difference_type | operator- (const IndexingIterator &other) const noexcept |
Computes the difference (i.e. the distance) between the positions of this iterator and another. More... | |
IndexingIterator | operator- (difference_type offset) const noexcept |
Rewinds iterator position a given offset , yielding a modified copy. More... | |
IndexingIterator & | operator-- () noexcept |
Pre-decrements iterator position in the target container. More... | |
IndexingIterator | operator-- (int) noexcept |
Post-decrements iterator position in the target container. More... | |
IndexingIterator & | operator-= (difference_type offset) noexcept |
Rewinds iterator position a given offset , in-place. More... | |
pointer | operator-> () const noexcept |
Dereferences iterator at its current position and yields a pointer to it. More... | |
bool | operator< (const IndexingIterator &other) const noexcept |
Checks if iterator position is strictly before that of another. More... | |
bool | operator<= (const IndexingIterator &other) const noexcept |
Checks if iterator position is before or equal to that of another. More... | |
bool | operator== (const IndexingIterator &other) const noexcept |
Checks if iterator position is equal to that of another. More... | |
bool | operator> (const IndexingIterator &other) const noexcept |
Checks if iterator position is strictly after that of another. More... | |
bool | operator>= (const IndexingIterator &other) const noexcept |
Checks if iterator position is after or equal to that of another. More... | |
reference | operator[] (difference_type offset) const noexcept |
Dereferences iterator at a given offset from its current position. More... | |
Private Attributes | |
Index | cursor_ {} |
Indexable * | indexable_ {nullptr} |
Friends | |
IndexingIterator | operator+ (difference_type offset, const IndexingIterator &iterator) |
Forwards iterator a given offset , yielding a modified copy. More... | |
A random access iterator for any indexable container.
It can provide a pair of iterators for any container type that supports subscripting with an integral-like index.
Indexable | Container type, potentially const. It must support subscripting. |
Index | Container index type. It must be default constructible and integral-like. Defaults to the indexable container size type, if defined. |
Definition at line 38 of file indexing_iterator.hpp.
using beluga::IndexingIterator< Indexable, Index >::difference_type = std::make_signed_t<decltype(std::declval<Index>() - std::declval<Index>())> |
Signed difference type of the iterator.
Definition at line 48 of file indexing_iterator.hpp.
using beluga::IndexingIterator< Indexable, Index >::iterator_category = std::random_access_iterator_tag |
Category of the iterator.
Definition at line 50 of file indexing_iterator.hpp.
using beluga::IndexingIterator< Indexable, Index >::pointer = decltype(std::addressof(std::declval<Indexable>()[std::declval<Index>()])) |
Value pointer type of the iterator.
Definition at line 46 of file indexing_iterator.hpp.
using beluga::IndexingIterator< Indexable, Index >::reference = decltype(std::declval<Indexable>()[std::declval<Index>()]) |
Value reference type of the iterator.
Definition at line 44 of file indexing_iterator.hpp.
using beluga::IndexingIterator< Indexable, Index >::value_type = std::remove_cv_t<std::remove_reference_t<decltype(std::declval<Indexable>()[std::declval<Index>()])> > |
Value type of the iterator.
Definition at line 42 of file indexing_iterator.hpp.
|
explicitdefault |
Default constructor. Iterator will point nowhere.
|
inlineexplicit |
Constructs iterator given a pointer to an indexable
container and a cursor
index on it.
Definition at line 56 of file indexing_iterator.hpp.
|
inlineexplicit |
Constructs iterator given a reference to an indexable
container and a cursor
index on it.
Definition at line 60 of file indexing_iterator.hpp.
|
inlinenoexcept |
Checks if iterator position is not equal to that of another.
Definition at line 193 of file indexing_iterator.hpp.
|
inlinenoexcept |
Dereferences iterator at its current position.
Behavior is undefined if the iterator is past the limits of the target container.
Definition at line 148 of file indexing_iterator.hpp.
|
inlinenoexcept |
Forwards iterator position a given offset
, yielding a modified copy.
Definition at line 101 of file indexing_iterator.hpp.
|
inlinenoexcept |
Pre-increments iterator position in the target container.
Definition at line 71 of file indexing_iterator.hpp.
|
inlinenoexcept |
Post-increments iterator position in the target container.
Definition at line 64 of file indexing_iterator.hpp.
|
inlinenoexcept |
Forwards iterator position a given offset
, in-place.
Definition at line 90 of file indexing_iterator.hpp.
|
inlinenoexcept |
Computes the difference (i.e. the distance) between the positions of this iterator and another.
Definition at line 131 of file indexing_iterator.hpp.
|
inlinenoexcept |
Rewinds iterator position a given offset
, yielding a modified copy.
Definition at line 124 of file indexing_iterator.hpp.
|
inlinenoexcept |
Pre-decrements iterator position in the target container.
Definition at line 84 of file indexing_iterator.hpp.
|
inlinenoexcept |
Post-decrements iterator position in the target container.
Definition at line 77 of file indexing_iterator.hpp.
|
inlinenoexcept |
Rewinds iterator position a given offset
, in-place.
Definition at line 113 of file indexing_iterator.hpp.
|
inlinenoexcept |
Dereferences iterator at its current position and yields a pointer to it.
Behavior is undefined if the iterator is past the limits of the target container.
Definition at line 154 of file indexing_iterator.hpp.
|
inlinenoexcept |
Checks if iterator position is strictly before that of another.
Can only be true for iterators that have the same target container.
Definition at line 160 of file indexing_iterator.hpp.
|
inlinenoexcept |
Checks if iterator position is before or equal to that of another.
Can only be true for iterators that have the same target container.
Definition at line 168 of file indexing_iterator.hpp.
|
inlinenoexcept |
Checks if iterator position is equal to that of another.
Can only be true for iterators that have the same target container.
Definition at line 188 of file indexing_iterator.hpp.
|
inlinenoexcept |
Checks if iterator position is strictly after that of another.
Can only be true for iterators that have the same target container.
Definition at line 176 of file indexing_iterator.hpp.
|
inlinenoexcept |
Checks if iterator position is after or equal to that of another.
Can only be true for iterators that have the same target container.
Definition at line 182 of file indexing_iterator.hpp.
|
inlinenoexcept |
Dereferences iterator at a given offset
from its current position.
Behavior is undefined for offsets that take the iterator past the limits of the target container.
Definition at line 142 of file indexing_iterator.hpp.
|
friend |
Forwards iterator
a given offset
, yielding a modified copy.
Definition at line 108 of file indexing_iterator.hpp.
|
private |
Definition at line 197 of file indexing_iterator.hpp.
|
private |
Definition at line 196 of file indexing_iterator.hpp.