dune-common 2.10
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
Dune::IndexedIterator< Iter > Class Template Reference

An iterator mixin that adds an index() method returning an enumeration index for the traversal. More...

#include <dune/common/indexediterator.hh>

Inheritance diagram for Dune::IndexedIterator< Iter >:
Inheritance graph

Public Types

using size_type = typename Traits::difference_type
 Type used for storing the traversal index.
 

Public Member Functions

template<class I = Iter, std::enable_if_t< std::is_default_constructible_v< I >, bool > = true>
constexpr IndexedIterator () noexcept(std::is_nothrow_default_constructible_v< Iter >)
 Default constructor default-constructs the Iter base type and the index by 0.
 
constexpr IndexedIterator (Iter it, size_type index=0) noexcept(std::is_nothrow_copy_constructible_v< Iter >)
 
constexpr size_type index () const noexcept
 Return the enumeration index.
 
constexpr IndexedIteratoroperator++ ()
 Increment the iterator and the index.
 
constexpr IndexedIterator operator++ (int)
 Increment the iterator and the index.
 
template<class I = Iter, decltype(--std::declval< I & >(), bool{}) = true>
constexpr IndexedIteratoroperator-- ()
 Decrement the iterator and the index.
 
template<class I = Iter, decltype(std::declval< I & >() --, bool{}) = true>
constexpr IndexedIterator operator-- (int)
 Decrement the iterator and the index.
 
template<class I = Iter, decltype(std::declval< I & >()+=1, bool{}) = true>
constexpr IndexedIteratoroperator+= (typename Iter::difference_type n)
 Increment the iterator and the index.
 
template<class I = Iter, decltype(std::declval< I & >() -=1, bool{}) = true>
constexpr IndexedIteratoroperator-= (typename Iter::difference_type n)
 Decrement the iterator and the index.
 

Detailed Description

template<class Iter>
class Dune::IndexedIterator< Iter >

An iterator mixin that adds an index() method returning an enumeration index for the traversal.

This is a mixin class that derives from its template parameter Iter and adds the method index() to retrieve an enumeration index during traversal. Only the increment and decrement operators are adapted to also increment (decrement) the accompanying index in the same way the iterator is incremented or decremented. Especially the dereference and comparison operators are not modified by this mixin class.

Template Parameters
IterAn iterator type from which the IndexedIterator will be derived.

Member Typedef Documentation

◆ size_type

template<class Iter >
using Dune::IndexedIterator< Iter >::size_type = typename Traits::difference_type

Type used for storing the traversal index.

Constructor & Destructor Documentation

◆ IndexedIterator() [1/2]

template<class Iter >
template<class I = Iter, std::enable_if_t< std::is_default_constructible_v< I >, bool > = true>
constexpr Dune::IndexedIterator< Iter >::IndexedIterator ( )
inlineconstexprnoexcept

Default constructor default-constructs the Iter base type and the index by 0.

◆ IndexedIterator() [2/2]

template<class Iter >
constexpr Dune::IndexedIterator< Iter >::IndexedIterator ( Iter  it,
size_type  index = 0 
)
inlineconstexprnoexcept

Construct the Iter base type by it and the index by the given starting index. Note that this constructor allows implicit conversion from Iter type.

Member Function Documentation

◆ index()

template<class Iter >
constexpr size_type Dune::IndexedIterator< Iter >::index ( ) const
inlineconstexprnoexcept

Return the enumeration index.

◆ operator++() [1/2]

template<class Iter >
constexpr IndexedIterator & Dune::IndexedIterator< Iter >::operator++ ( )
inlineconstexpr

Increment the iterator and the index.

◆ operator++() [2/2]

template<class Iter >
constexpr IndexedIterator Dune::IndexedIterator< Iter >::operator++ ( int  )
inlineconstexpr

Increment the iterator and the index.

◆ operator+=()

template<class Iter >
template<class I = Iter, decltype(std::declval< I & >()+=1, bool{}) = true>
constexpr IndexedIterator & Dune::IndexedIterator< Iter >::operator+= ( typename Iter::difference_type  n)
inlineconstexpr

Increment the iterator and the index.

◆ operator--() [1/2]

template<class Iter >
template<class I = Iter, decltype(--std::declval< I & >(), bool{}) = true>
constexpr IndexedIterator & Dune::IndexedIterator< Iter >::operator-- ( )
inlineconstexpr

Decrement the iterator and the index.

◆ operator--() [2/2]

template<class Iter >
template<class I = Iter, decltype(std::declval< I & >() --, bool{}) = true>
constexpr IndexedIterator Dune::IndexedIterator< Iter >::operator-- ( int  )
inlineconstexpr

Decrement the iterator and the index.

◆ operator-=()

template<class Iter >
template<class I = Iter, decltype(std::declval< I & >() -=1, bool{}) = true>
constexpr IndexedIterator & Dune::IndexedIterator< Iter >::operator-= ( typename Iter::difference_type  n)
inlineconstexpr

Decrement the iterator and the index.


The documentation for this class was generated from the following file: