Dune Core Modules (unstable)

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>

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.

Constructor & Destructor Documentation

◆ IndexedIterator()

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.


The documentation for this class was generated from the following file:
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 20, 23:30, 2024)