|
SeqAn3 3.4.0-rc.4
The Modern C++ library for sequence analysis.
|
A CRTP base template for creating random access iterators. More...
#include <seqan3/core/range/detail/random_access_iterator.hpp>
Inheritance diagram for seqan3::detail::random_access_iterator_base< range_type, derived_t_template, args_t >:Public Types | |
| using | const_reference = typename range_type::const_reference |
| Use const reference type provided by container. | |
| using | difference_type = typename range_type::difference_type |
| Type for distances between iterators. | |
| using | iterator_category = std::random_access_iterator_tag |
| Tag this class as a random access iterator. | |
| using | pointer = value_type * |
| Pointer type is pointer of container element type. | |
| using | reference = std::conditional_t< std::is_const_v< range_type >, typename range_type::const_reference, typename range_type::reference > |
| Use reference type defined by container. | |
| using | value_type = typename range_type::value_type |
| Value type of container elements. | |
Protected Types | |
| using | derived_t = derived_t_template< range_type > |
| Because this is CRTP, we know the full derived type: | |
| using | position_type = std::make_unsigned_t< typename range_type::difference_type > |
| Use container's size_type as a position. | |
Protected Attributes | |
| std::add_pointer_t< range_type > | host {nullptr} |
| Iterator stores pointer to underlying container structure. | |
| position_type | pos {static_cast<position_type>(0)} |
| Store position index for container. | |
Private Member Functions | |
| constexpr derived_t * | this_derived () |
| Cast this to derived type. | |
| constexpr derived_t const * | this_derived () const |
| Cast this to derived type. | |
Friends | |
| template<typename range_type2 , template< typename... > typename derived_t_template2, typename... args2_t> | |
| class | random_access_iterator_base |
| This friend declaration is required to allow non-const to const-construction. | |
Arithmetic operators | |
seqan3::detail::random_access_iterator_base operators are used unless specialised in derived type. | |
| constexpr friend derived_t | operator+ (difference_type const skip, derived_t const &it) noexcept |
| Non-member operator+ delegates to non-friend operator+. | |
| constexpr friend derived_t | operator- (difference_type const skip, derived_t const &it) noexcept |
| Non-member operator- delegates to non-friend operator-. | |
| constexpr friend difference_type | operator- (derived_t const &lhs, derived_t const &rhs) noexcept |
| Return offset between this and remote iterator's position. | |
| constexpr derived_t & | operator++ () noexcept |
| Pre-increment, return updated iterator. | |
| constexpr derived_t | operator++ (int) noexcept |
| Post-increment, return previous iterator state. | |
| constexpr derived_t & | operator-- () noexcept |
| Pre-decrement, return updated iterator. | |
| constexpr derived_t | operator-- (int) noexcept |
| Post-decrement, return previous iterator state. | |
| constexpr derived_t & | operator+= (difference_type const skip) noexcept |
| Forward this iterator. | |
| constexpr derived_t | operator+ (difference_type const skip) const noexcept |
| Forward copy of this iterator. | |
| constexpr derived_t & | operator-= (difference_type const skip) noexcept |
| Decrement iterator by skip. | |
| constexpr derived_t | operator- (difference_type const skip) const noexcept |
| Return decremented copy of this iterator. | |
A CRTP base template for creating random access iterators.
| range_type | The data structure on which the iterator operates, e.g. std::vector<int>. |
| derived_t_template | The derived type template, see below. |
The iterator makes certain assumptions on the range_type, but does not formally require it to satisfy the std::ranges::random_access_range, because the iterator itself may be a requirement for this.
Actual functionality of this iterator is realised via the host range's [] operator and member type definitions, i.e. you need to implement these in the range before you can make use of this iterator.
Since the CRTP parameter is in fact a template template, CRTP instantiation looks a little different, e.g.:
|
inlineconstexprprivate |
Cast this to derived type.