4.6.0
Freundlich's C++ toolkit
Loading...
Searching...
No Matches
fcppt::iterator::base< Types > Class Template Reference

Detailed Description

template<typename Types>
class fcppt::iterator::base< Types >

A template for implementing iterators.

This class is meant to be derived from in order to implement an iterator. It provides all functions to fulfil the iterator requirements of a specific iterator category. The derived class D is expected to implement certain public functions depending on what the category is:

  • Input iterator:
    • void increment(): Increments the iterator.
    • bool equal(D) const: Compares two iterators for equality.
    • Types::reference dereference() const: Returns the current element.
  • Forward iterator:
    • Types::reference must be Types::value_type (const) &.
    • D must have a default constructor.
  • Bidirectional iterator:
    • void decrement(): Decrements the iterator.
  • Random Access iterator:
    • void advance(Types::difference_type): Moves the iterator forwards/backwards.
    • Types::difference_type distance_to(D) const: The value to advance *this with in order to be equal to the argument.
Template Parameters
TypesMust be an fcppt::iterator::types.
Inheritance diagram for fcppt::iterator::base< Types >:
fcppt::container::tree::pre_order< Tree >::iterator fcppt::container::tree::to_root< Tree >::iterator

Public Types

using derived = typename Types::derived
 
using value_type = typename Types::value_type
 
using reference = typename Types::reference
 
using difference_type = typename Types::difference_type
 
using pointer = std::add_pointer_t<reference>
 
using iterator_category = typename Types::iterator_category
 

Public Member Functions

reference operator* () const
 
derivedoperator++ ()
 
bool operator== (base const &) const
 
bool operator!= (base const &) const
 
pointer operator-> () const
 
derived operator++ (int)
 
void swap (base &) noexcept
 
derivedoperator-- ()
 
derived operator-- (int)
 
derivedoperator+= (difference_type)
 
derived operator+ (difference_type) const
 
derivedoperator-= (difference_type)
 
derived operator- (difference_type) const
 
reference operator[] (difference_type) const
 
difference_type operator- (base const &) const
 

Protected Member Functions

 base ()
 

Member Typedef Documentation

◆ derived

template<typename Types >
using fcppt::iterator::base< Types >::derived = typename Types::derived

◆ difference_type

template<typename Types >
using fcppt::iterator::base< Types >::difference_type = typename Types::difference_type

◆ iterator_category

template<typename Types >
using fcppt::iterator::base< Types >::iterator_category = typename Types::iterator_category

◆ pointer

template<typename Types >
using fcppt::iterator::base< Types >::pointer = std::add_pointer_t<reference>

◆ reference

template<typename Types >
using fcppt::iterator::base< Types >::reference = typename Types::reference

◆ value_type

template<typename Types >
using fcppt::iterator::base< Types >::value_type = typename Types::value_type

Constructor & Destructor Documentation

◆ base()

template<typename Types >
fcppt::iterator::base< Types >::base ( )
protected

Member Function Documentation

◆ operator!=()

template<typename Types >
bool fcppt::iterator::base< Types >::operator!= ( base< Types > const & ) const
nodiscard

◆ operator*()

template<typename Types >
reference fcppt::iterator::base< Types >::operator* ( ) const
nodiscard

◆ operator+()

template<typename Types >
derived fcppt::iterator::base< Types >::operator+ ( difference_type ) const
nodiscard

◆ operator++() [1/2]

template<typename Types >
derived & fcppt::iterator::base< Types >::operator++ ( )

◆ operator++() [2/2]

template<typename Types >
derived fcppt::iterator::base< Types >::operator++ ( int )
nodiscard

◆ operator+=()

template<typename Types >
derived & fcppt::iterator::base< Types >::operator+= ( difference_type )

◆ operator-() [1/2]

template<typename Types >
difference_type fcppt::iterator::base< Types >::operator- ( base< Types > const & ) const
nodiscard

◆ operator-() [2/2]

template<typename Types >
derived fcppt::iterator::base< Types >::operator- ( difference_type ) const
nodiscard

◆ operator--() [1/2]

template<typename Types >
derived & fcppt::iterator::base< Types >::operator-- ( )

◆ operator--() [2/2]

template<typename Types >
derived fcppt::iterator::base< Types >::operator-- ( int )
nodiscard

◆ operator-=()

template<typename Types >
derived & fcppt::iterator::base< Types >::operator-= ( difference_type )

◆ operator->()

template<typename Types >
pointer fcppt::iterator::base< Types >::operator-> ( ) const
nodiscard

◆ operator==()

template<typename Types >
bool fcppt::iterator::base< Types >::operator== ( base< Types > const & ) const
nodiscard

◆ operator[]()

template<typename Types >
reference fcppt::iterator::base< Types >::operator[] ( difference_type ) const
nodiscard

◆ swap()

template<typename Types >
void fcppt::iterator::base< Types >::swap ( base< Types > & )
noexcept