Dune Core Modules (2.5.0)
Generic class for stl-conforming iterators for container classes with operator[]. More...
#include <dune/common/genericiterator.hh>
Public Types | |
typedef C | Container |
The type of container we are an iterator for. More... | |
typedef T | Value |
The value type of the iterator. More... | |
typedef D | DifferenceType |
The type of the difference between two positions. | |
typedef R | Reference |
The type of the reference to the values accessed. | |
typedef GenericIterator< C, T, T &, std::ptrdiff_t, RandomAccessIteratorFacade > | DerivedType |
The type of derived iterator. More... | |
typedef T * | Pointer |
The pointer to the Value. | |
Public Member Functions | |
GenericIterator (Container &cont, DifferenceType pos) | |
Constructor. More... | |
GenericIterator (const MutableIterator &other) | |
Copy constructor. More... | |
GenericIterator (const ConstIterator &other) | |
Copy constructor. More... | |
Reference | operator* () const |
Dereferencing operator. | |
Reference | operator[] (DifferenceType n) const |
Get the element n positions from the current one. More... | |
DerivedType & | operator++ () |
Preincrement operator. | |
DerivedType | operator++ (int) |
Postincrement operator. | |
DerivedType & | operator-- () |
Predecrement operator. | |
DerivedType | operator-- (int) |
Postdecrement operator. | |
Detailed Description
class Dune::GenericIterator< C, T, R, D, IteratorFacade >
Generic class for stl-conforming iterators for container classes with operator[].
If template parameter C has a const qualifier we are a const iterator, otherwise we are a mutable iterator.
Member Typedef Documentation
◆ Container
typedef C Dune::GenericIterator< C, T, R, D, IteratorFacade >::Container |
The type of container we are an iterator for.
The container type must provide an operator[] method.
If C has a const qualifier we are a const iterator, otherwise we are a mutable iterator.
◆ DerivedType
|
inherited |
The type of derived iterator.
The iterator has to define following functions have to be present:
For an elaborate explanation see the STL Documentation
◆ Value
typedef T Dune::GenericIterator< C, T, R, D, IteratorFacade >::Value |
The value type of the iterator.
This is the return type when dereferencing the iterator.
Constructor & Destructor Documentation
◆ GenericIterator() [1/3]
|
inline |
Constructor.
- Parameters
-
cont Reference to the container we are an iterator for pos The position the iterator will be positioned to (e.g. 0 for an iterator returned by Container::begin() or the size of the container for an iterator returned by Container::end()
◆ GenericIterator() [2/3]
|
inline |
Copy constructor.
This is somehow hard to understand, therefore play with the cases:
- if we are mutable this is the only valid copy constructor, as the argument is a mutable iterator
- if we are a const iterator the argument is a mutable iterator => This is the needed conversion to initialize a const iterator from a mutable one.
◆ GenericIterator() [3/3]
|
inline |
Copy constructor.
- Warning
- Calling this method results in a compiler error, if this is a mutable iterator.
This is somehow hard to understand, therefore play with the cases:
- if we are mutable the arguments is a const iterator and therefore calling this method is mistake in the user's code and results in a (probably not understandable) compiler error
- If we are a const iterator this is the default copy constructor as the argument is a const iterator too.
Member Function Documentation
◆ operator[]()
|
inlineinherited |
Get the element n positions from the current one.
- Parameters
-
n The distance to the element.
- Returns
- The element at that distance.
The documentation for this class was generated from the following file:
- dune/common/genericiterator.hh