SpECTRE
v2025.03.17
|
Base class to generate methods for a random-access iterator. This class takes the derived class and the (optionally const
) value_type
of the iterator. The exposed value_type
alias will always be non-const, as required by the standard, but the template parameter's constness will affect the reference
and pointer
aliases.
More...
#include <StlBoilerplate.hpp>
Public Types | |
using | iterator_category = std::random_access_iterator_tag |
using | value_type = std::remove_const_t< ValueType > |
using | reference = ValueType & |
using | pointer = ValueType * |
using | difference_type = std::ptrdiff_t |
Public Member Functions | |
pointer | operator-> () const |
Iter & | operator++ () |
Iter | operator++ (int) |
Iter & | operator-- () |
Iter | operator-- (int) |
Iter & | operator-= (const difference_type n) |
reference | operator[] (const difference_type n) const |
Protected Member Functions | |
RandomAccessIterator (const RandomAccessIterator &)=default | |
RandomAccessIterator (RandomAccessIterator &&)=default | |
RandomAccessIterator & | operator= (const RandomAccessIterator &)=default |
RandomAccessIterator & | operator= (RandomAccessIterator &&)=default |
Base class to generate methods for a random-access iterator. This class takes the derived class and the (optionally const
) value_type
of the iterator. The exposed value_type
alias will always be non-const, as required by the standard, but the template parameter's constness will affect the reference
and pointer
aliases.
The derived class must implement operator*
, operator+=
, operator-
(of two iterators), and operator==
.
This class is inspired by Boost's iterator_facade
, except that that has a lot of special cases, some of which work poorly because they predate C++11.