SeqAn3 3.4.0-rc.4
The Modern C++ library for sequence analysis.
|
A CRTP base template for creating iterators that inherit from other iterators. More...
#include <seqan3/core/range/detail/inherited_iterator_base.hpp>
Public Types | |
Associated types | |
All are derived from the base_t. | |
using | difference_type = std::iter_difference_t< base_t > |
The difference type. | |
using | value_type = std::iter_value_t< base_t > |
The value type. | |
using | reference = std::iter_reference_t< base_t > |
The reference type. | |
using | pointer = detail::iter_pointer_t< base_t > |
The pointer type. | |
using | iterator_category = maybe_present |
The iterator category tag. | |
using | iterator_concept = detail::iterator_concept_tag_t< base_t > |
The iterator concept tag. | |
![]() | |
using | iterator_category = MAYBE_PRESENT(std::iterator_traits< underlying_iterator_t >::iterator_category) |
The iterator category tag. (not always present!) | |
Public Member Functions | |
constexpr base_t | base () &&noexcept |
Returns an rvalue of the base. | |
constexpr base_t & | base () &noexcept |
Get a reference to the base. | |
constexpr base_t const & | base () const &noexcept |
Get a const reference to the base. | |
Constructors, destructor and assignment | |
The exception specification is explicitly "inherited" to also work for pointers as base. | |
constexpr | inherited_iterator_base () noexcept(std::is_nothrow_default_constructible_v< base_t >)=default |
Defaulted. | |
constexpr | inherited_iterator_base (inherited_iterator_base const &rhs) noexcept(std::is_nothrow_copy_constructible_v< base_t >)=default |
Defaulted. | |
constexpr | inherited_iterator_base (inherited_iterator_base &&rhs) noexcept(std::is_nothrow_move_constructible_v< base_t >)=default |
Defaulted. | |
constexpr inherited_iterator_base & | operator= (inherited_iterator_base const &rhs) noexcept(std::is_nothrow_copy_assignable_v< base_t >)=default |
Defaulted. | |
constexpr inherited_iterator_base & | operator= (inherited_iterator_base &&rhs) noexcept(std::is_nothrow_move_assignable_v< base_t >)=default |
Defaulted. | |
~inherited_iterator_base () noexcept(std::is_nothrow_destructible_v< base_t >)=default | |
Defaulted. | |
constexpr | inherited_iterator_base (base_t it) noexcept(std::is_nothrow_move_constructible_v< base_t >) |
Delegate to base class if inheriting from non-pointer iterator. | |
constexpr | inherited_iterator_base (base_t it) noexcept |
Initialise member if deriving from pointer. | |
Comparison operators | |
Unless specialised in derived_type, all operators perform base_t's operator and cast to derived_t. | |
constexpr bool | operator== (derived_t const &rhs) const noexcept(noexcept(std::declval< base_t & >()==std::declval< base_t & >())) |
Checks whether *this is equal to rhs . | |
constexpr bool | operator!= (derived_t const &rhs) const noexcept(noexcept(std::declval< base_t & >()==std::declval< base_t & >())) |
Checks whether *this is not equal to rhs . | |
constexpr bool | operator< (derived_t const &rhs) const noexcept(noexcept(std::declval< base_t & >()< std::declval< base_t & >())) |
Checks whether *this is less than rhs . | |
constexpr bool | operator> (derived_t const &rhs) const noexcept(noexcept(std::declval< base_t & >() > std::declval< base_t & >())) |
Checks whether *this is greater than rhs . | |
constexpr bool | operator<= (derived_t const &rhs) const noexcept(noexcept(std::declval< base_t & >() > std::declval< base_t & >())) |
Checks whether *this is less than or equal to rhs . | |
constexpr bool | operator>= (derived_t const &rhs) const noexcept(noexcept(std::declval< base_t & >()< std::declval< base_t & >())) |
Checks whether *this is greater than or equal to rhs . | |
Reference/Dereference operators | |
constexpr reference | operator* () noexcept(noexcept(*std::declval< base_t & >())) |
Dereference operator returns element currently pointed at. | |
constexpr decltype(auto) | operator* () const noexcept(noexcept(*std::declval< base_t const & >())) |
Dereference operator returns element currently pointed at. | |
constexpr pointer | operator-> () noexcept(noexcept(*std::declval< base_t & >())) |
Return pointer to this iterator. | |
constexpr decltype(auto) | operator-> () const noexcept(noexcept(*std::declval< base_t const & >())) |
Return pointer to this iterator. | |
constexpr decltype(auto) | operator[] (std::make_signed_t< difference_type > const n) noexcept(noexcept(std::declval< base_t & >()[0])) |
Return underlying container value currently pointed at. | |
constexpr decltype(auto) | operator[] (std::make_signed_t< difference_type > const n) const noexcept(noexcept(std::declval< base_t const & >()[0])) |
Return underlying container value currently pointed at. | |
Private Member Functions | |
constexpr base_t & | as_base () &noexcept |
Cast this to base type. | |
constexpr base_t const & | as_base () const &noexcept |
Cast this to base type. | |
constexpr derived_t * | this_derived () |
Cast this to derived type. | |
constexpr derived_t const * | this_derived () const |
Cast this to derived type. | |
Private Attributes | |
friend | derived_t |
Befriend the derived type so it can access the private members. | |
std::conditional_t< wrap_base, base_t, empty_type > | member |
If the base is a pointer, we wrap it instead of inheriting. | |
Static Private Attributes | |
static constexpr bool | wrap_base = std::is_pointer_v<base_t> || !std::semiregular<base_t> |
Whether this iterator inherits or wraps. | |
Arithmetic operators | |
Unless specialised in derived_type, all operators perform base_t's operator and cast to derived_t. | |
constexpr derived_t & | operator++ () noexcept(noexcept(++std::declval< base_t & >())) |
Pre-increment, return updated iterator. | |
constexpr auto | operator++ (int) noexcept(noexcept(std::declval< base_t & >()++)) |
Post-increment of input iterators that do not return a copy of themselves but void or a proxy type. | |
constexpr derived_t | operator++ (int) noexcept(noexcept(std::declval< base_t & >()++) &&std::is_nothrow_copy_constructible_v< derived_t >) |
Post-increment, return previous iterator state. | |
constexpr derived_t & | operator-- () noexcept(noexcept(--std::declval< base_t & >())) |
Pre-decrement, return updated iterator. | |
constexpr derived_t | operator-- (int) noexcept(noexcept(std::declval< base_t & >() --) &&std::is_nothrow_copy_constructible_v< derived_t >) |
Post-decrement, return previous iterator state. | |
constexpr derived_t & | operator+= (difference_type const skip) noexcept(noexcept(std::declval< base_t & >()+=skip)) |
Move iterator to the right. | |
constexpr derived_t | operator+ (difference_type const skip) const noexcept(noexcept(std::declval< base_t & >()+skip) &&std::is_nothrow_copy_constructible_v< derived_t >) |
Returns an iterator which is advanced by skip positions. | |
constexpr derived_t & | operator-= (difference_type const skip) noexcept(noexcept(std::declval< base_t & >() -=skip)) |
Decrement iterator by skip. | |
constexpr derived_t | operator- (difference_type const skip) const noexcept(noexcept(std::declval< base_t const & >() - skip) &&std::is_nothrow_copy_constructible_v< derived_t >) |
Return decremented copy of this iterator. | |
constexpr difference_type | operator- (derived_t const &rhs) const noexcept(noexcept(std::declval< base_t & >() - std::declval< base_t & >())) |
Return offset between this and remote iterator's position. | |
constexpr friend derived_t | operator+ (difference_type const skip, derived_t const &it) noexcept(noexcept(skip+std::declval< base_t const & >())) |
Non-member operator+ delegates to non-friend operator+. | |
A CRTP base template for creating iterators that inherit from other iterators.
derived_t | The CRTP specialisation. |
base_t | The type to inherit from; must satisfy std::input_or_output_iterator. |
This template enables you to inherit from another iterator and just overload those functions that you wish to change.
Note that many of this class's members assume that the derived type is constructible from the base type.
You may want to have an iterator that skips those elements in an int-vector that are not divisable by two:
You could define it like this:
|
no-apiinlineconstexprprivatenoexcept |
Cast this to base type.
|
no-apiinlineconstexprprivate |
Cast this to derived type.