#include <utility.hh>
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.
The following example implements a function object which counts the elements in a tuple
template <class T> struct Counter { Counter() : result_(0) {} template <class T> void visit(T& elem) { ++result_; } int result_; };
Counter c;
ForEachValue<MyTuple> forEach(t);
forEach.apply(c);
std::cout << "Number of elements is: " << c.result_ << std::endl;
Public Member Functions | |
ForEachValue (TupleType &tuple) | |
Constructor. | |
template<class Functor> | |
void | apply (Functor &f) |
Applies a function object to each storage element of the tuple. |
Dune::ForEachValue< TupleType >::ForEachValue | ( | TupleType & | tuple | ) | [inline] |
void Dune::ForEachValue< TupleType >::apply | ( | Functor & | f | ) | [inline] |