dune-common
2.2.1
|
helper class to implement transformTuple() More...
#include <dune/common/tupleutility.hh>
Classes | |
struct | TypeEvaluator |
export the TypeEvaluator template class for genericTransformTuple() More... |
Public Member Functions | |
TransformTupleFunctor (A0 &a0_, A1 &a1_, A2 &a2_, A3 &a3_, A4 &a4_, A5 &a5_, A6 &a6_, A7 &a7_, A8 &a8_, A9 &a9_) | |
constructor | |
template<class T > | |
TE< T >::Type | operator() (T &t) const |
call TE<T>::apply (t,args...) |
helper class to implement transformTuple()
\tparam TE TypeEvaluator class template. \tparam An Type of extra arguments to pass to \c TE<T>::apply(). \c void means "no argument". Only trailing arguments may be void. This class stores references to a number of arguments it receives in the constructor. Later, its function call operator \c operator() may be called with a parameter \c t of type \c T. \c operator() will then call the static method \c TE<T>::apply(t,args...), where \c args... is the sequence of arguments the object was constructed with. \c operator() will convert the result to type \c TE<T>::Type and return it. \c TE should be an extended version of the \c TypeEvaluator class template parameter of ForEachType, for instance: @code
template <class t>=""> struct TypeEvaluator { typedef T* Type; static Type apply(T& t, void* a0) { return t ? &t : static_cast<T*>(a0); } }; This example is for a TransformTupleFunctor with one argument, i.e. A0!=void
and all other An=void
. For the type transformation, it will transform a value of some type T into a pointer to T. For the value transformation, it will take a reference to a value of type T and return the pointer to that value, unless the value evaluates to false in boolean context. If the value evaluates to false, it will instead return the pointer from the extra argument.
|
inline |
constructor
The actual number of arguments varies between specializations, the actual number of arguments here is equal to the number of non-void
class template arguments An
.
|
inline |
call TE<T>::apply
(t,args...)
This calls the static apply method of the TypeEvaluator class template.
operator()
with at const
T&
argument, since genericTransformTuple() will always use an lvalue argument.