Loading...
Searching...
No Matches
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 >:

## 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 IndexedIterator & | operator++ ()
| 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 IndexedIterator & | operator-- ()
| 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 IndexedIterator & | operator+= (typename Iter::difference_type n)
| Increment the iterator and the index.
template<class I = Iter, decltype(std::declval< I & >() -=1, bool{}) = true>
constexpr IndexedIterator & | operator-= (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

  Iter | An 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>

Dune::IndexedIterator< Iter >::IndexedIterator | ( |  | ) |

inline constexpr noexcept

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

## IndexedIterator() [2/2]

template<class Iter>

Dune::IndexedIterator< Iter >::IndexedIterator | ( | Iter | it,
|  | size_type | index = 0 )

inline constexpr noexcept

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>

size_type Dune::IndexedIterator< Iter >::index | ( |  | ) | const

inline nodiscard constexpr noexcept

Return the enumeration index.

## operator++() [1/2]

template<class Iter>

IndexedIterator & Dune::IndexedIterator< Iter >::operator++ | ( |  | ) |

inline constexpr

Increment the iterator and the index.

## operator++() [2/2]

template<class Iter>

IndexedIterator Dune::IndexedIterator< Iter >::operator++ | ( | int |  | ) |

inline constexpr

Increment the iterator and the index.

## operator+=()

template<class Iter>
template<class I = Iter, decltype(std::declval< I & >()+=1, bool{}) = true>

IndexedIterator & Dune::IndexedIterator< Iter >::operator+= | ( | typename Iter::difference_type | n | ) |

inline constexpr

Increment the iterator and the index.

## operator--() [1/2]

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

IndexedIterator & Dune::IndexedIterator< Iter >::operator-- | ( |  | ) |

inline constexpr

Decrement the iterator and the index.

## operator--() [2/2]

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

IndexedIterator Dune::IndexedIterator< Iter >::operator-- | ( | int |  | ) |

inline constexpr

Decrement the iterator and the index.

## operator-=()

template<class Iter>
template<class I = Iter, decltype(std::declval< I & >() -=1, bool{}) = true>

IndexedIterator & Dune::IndexedIterator< Iter >::operator-= | ( | typename Iter::difference_type | n | ) |

inline constexpr

Decrement the iterator and the index.

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

- indexediterator.hh