|
dune-common
2.3.1
|
Helper template which implements iteration over all storage elements in a tuple. More...
#include <dune/common/tupleutility.hh>
Public Member Functions | |
| ForEachValue (TupleType &tuple) | |
| Constructor. More... | |
| template<class Functor > | |
| void | apply (Functor &f) const |
| Applies a function object to each storage element of the tuple. More... | |
Helper template which implements iteration over all storage elements in a tuple.
Compile-time constructs that allows to process all elements in a tuple. The exact operation performed on an element is defined by a function object, which needs to implement a visit method which is applicable to all storage elements of a tuple. Each tuple element is visited once, and the iteration is done in ascending order.
The following example implements a function object which counts the elements in a tuple
The number of elements in the tuple are stored in the member variable result_. The Counter can be used as follows, assuming a tuple t of type MyTuple is given:
|
inline |
Constructor.
| tuple | The tuple which we want to process. |
|
inline |
Applies a function object to each storage element of the tuple.
| f | Function object. |
1.8.7