dune-common 2.1.1
|
A static loop using TMP. More...
#include <dune/common/forloop.hh>
Static Public Member Functions | |
static void | apply () |
static void | apply (T1 &p1) |
static void | apply (T1 &p1, T2 &p2) |
static void | apply (T1 &p1, T2 &p2, T3 &p3) |
static void | apply (T1 &p1, T2 &p2, T3 &p3, T4 &p4) |
static void | apply (T1 &p1, T2 &p2, T3 &p3, T4 &p4, T5 &p5) |
static void | apply (T1 &p1, T2 &p2, T3 &p3, T4 &p4, T5 &p5, T6 &p6) |
static void | apply (T1 &p1, T2 &p2, T3 &p3, T4 &p4, T5 &p5, T6 &p6, T7 &p7) |
static void | apply (T1 &p1, T2 &p2, T3 &p3, T4 &p4, T5 &p5, T6 &p6, T7 &p7, T8 &p8) |
static void | apply (T1 &p1, T2 &p2, T3 &p3, T4 &p4, T5 &p5, T6 &p6, T7 &p7, T8 &p8, T9 &p9) |
static void | apply (T1 &p1, T2 &p2, T3 &p3, T4 &p4, T5 &p5, T6 &p6, T7 &p7, T8 &p8, T9 &p9, T10 &p10) |
static void | apply (T1 &p1, T2 &p2, T3 &p3, T4 &p4, T5 &p5, T6 &p6, T7 &p7, T8 &p8, T9 &p9, T10 &p10, T11 &p11) |
static void | apply (T1 &p1, T2 &p2, T3 &p3, T4 &p4, T5 &p5, T6 &p6, T7 &p7, T8 &p8, T9 &p9, T10 &p10, T11 &p11, T12 &p12) |
static void | apply (T1 &p1, T2 &p2, T3 &p3, T4 &p4, T5 &p5, T6 &p6, T7 &p7, T8 &p8, T9 &p9, T10 &p10, T11 &p11, T12 &p12, T13 &p13) |
A static loop using TMP.
The ForLoop takes a
template<int i> class Operation
template argument with a static apply method which is called for i=first...last (first<=last are int template arguments). A specialization for class template class Operation for i=first or i=last is not required. The class Operation must provide a static void function apply(...). Arguments (as references) can be passed through the ForLoop to this function (up to 5 at the moment).
It is possible to pass a subclass to the ForLoop (since no specialization is needed).
Example of usage:
template<class Tuple> struct PrintTupleTypes { template <int i> struct Operation { template<class Stream> static void apply(Stream &stream, const std::string &prefix) { stream << prefix << i << ": " << className<typename tuple_element<i, Tuple>::type>() << std::endl; } }; template<class Stream> static void print(Stream &stream, const std::string &prefix) { // cannot attach on-the-fly in the argument to ForLoop<..>::apply() since // that would yield an rvalue std::string extended_prefix = prefix+" "; stream << prefix << "tuple<" << std::endl; ForLoop<Operation, 0, tuple_size<Tuple>::value-1>:: apply(stream, extended_prefix); stream << prefix << ">" << std::endl; } };
Rvalues will bind to const-references, but not to references that are non-const. Since we do want to support modifiable arguments to apply(), we have to use non-const references as arguments. Supporting const references as well would lead to an insane number of overloads which all have to be written more-or-less by hand.
Examples of rvalues are: literals (1.0, 0, "huhu"), the results of functions returning an object (std::make_pair(0, 1.0)) and temporary object constructions (std::string("hello"));
static void Dune::ForLoopHelper::Apply< Operation< first > , GenericForLoop< ForLoopHelper::Apply, Operation, first+1, last > >::apply | ( | ) | [inline, static, inherited] |
References Dune::ForLoopHelper::Apply< A, B >::apply().
static void Dune::ForLoopHelper::Apply< Operation< first > , GenericForLoop< ForLoopHelper::Apply, Operation, first+1, last > >::apply | ( | T1 & | p1, |
T2 & | p2, | ||
T3 & | p3, | ||
T4 & | p4, | ||
T5 & | p5, | ||
T6 & | p6, | ||
T7 & | p7, | ||
T8 & | p8, | ||
T9 & | p9, | ||
T10 & | p10, | ||
T11 & | p11, | ||
T12 & | p12, | ||
T13 & | p13 | ||
) | [inline, static, inherited] |
References Dune::ForLoopHelper::Apply< A, B >::apply().
static void Dune::ForLoopHelper::Apply< Operation< first > , GenericForLoop< ForLoopHelper::Apply, Operation, first+1, last > >::apply | ( | T1 & | p1, |
T2 & | p2, | ||
T3 & | p3, | ||
T4 & | p4, | ||
T5 & | p5, | ||
T6 & | p6, | ||
T7 & | p7, | ||
T8 & | p8, | ||
T9 & | p9, | ||
T10 & | p10, | ||
T11 & | p11, | ||
T12 & | p12 | ||
) | [inline, static, inherited] |
References Dune::ForLoopHelper::Apply< A, B >::apply().
static void Dune::ForLoopHelper::Apply< Operation< first > , GenericForLoop< ForLoopHelper::Apply, Operation, first+1, last > >::apply | ( | T1 & | p1, |
T2 & | p2, | ||
T3 & | p3, | ||
T4 & | p4, | ||
T5 & | p5, | ||
T6 & | p6, | ||
T7 & | p7, | ||
T8 & | p8, | ||
T9 & | p9, | ||
T10 & | p10, | ||
T11 & | p11 | ||
) | [inline, static, inherited] |
References Dune::ForLoopHelper::Apply< A, B >::apply().
static void Dune::ForLoopHelper::Apply< Operation< first > , GenericForLoop< ForLoopHelper::Apply, Operation, first+1, last > >::apply | ( | T1 & | p1, |
T2 & | p2, | ||
T3 & | p3, | ||
T4 & | p4, | ||
T5 & | p5, | ||
T6 & | p6, | ||
T7 & | p7, | ||
T8 & | p8, | ||
T9 & | p9, | ||
T10 & | p10 | ||
) | [inline, static, inherited] |
References Dune::ForLoopHelper::Apply< A, B >::apply().
static void Dune::ForLoopHelper::Apply< Operation< first > , GenericForLoop< ForLoopHelper::Apply, Operation, first+1, last > >::apply | ( | T1 & | p1, |
T2 & | p2, | ||
T3 & | p3, | ||
T4 & | p4, | ||
T5 & | p5, | ||
T6 & | p6, | ||
T7 & | p7, | ||
T8 & | p8, | ||
T9 & | p9 | ||
) | [inline, static, inherited] |
References Dune::ForLoopHelper::Apply< A, B >::apply().
static void Dune::ForLoopHelper::Apply< Operation< first > , GenericForLoop< ForLoopHelper::Apply, Operation, first+1, last > >::apply | ( | T1 & | p1, |
T2 & | p2, | ||
T3 & | p3, | ||
T4 & | p4, | ||
T5 & | p5, | ||
T6 & | p6, | ||
T7 & | p7, | ||
T8 & | p8 | ||
) | [inline, static, inherited] |
References Dune::ForLoopHelper::Apply< A, B >::apply().
static void Dune::ForLoopHelper::Apply< Operation< first > , GenericForLoop< ForLoopHelper::Apply, Operation, first+1, last > >::apply | ( | T1 & | p1, |
T2 & | p2, | ||
T3 & | p3, | ||
T4 & | p4, | ||
T5 & | p5, | ||
T6 & | p6, | ||
T7 & | p7 | ||
) | [inline, static, inherited] |
References Dune::ForLoopHelper::Apply< A, B >::apply().
static void Dune::ForLoopHelper::Apply< Operation< first > , GenericForLoop< ForLoopHelper::Apply, Operation, first+1, last > >::apply | ( | T1 & | p1, |
T2 & | p2, | ||
T3 & | p3, | ||
T4 & | p4, | ||
T5 & | p5, | ||
T6 & | p6 | ||
) | [inline, static, inherited] |
References Dune::ForLoopHelper::Apply< A, B >::apply().
static void Dune::ForLoopHelper::Apply< Operation< first > , GenericForLoop< ForLoopHelper::Apply, Operation, first+1, last > >::apply | ( | T1 & | p1, |
T2 & | p2, | ||
T3 & | p3, | ||
T4 & | p4, | ||
T5 & | p5 | ||
) | [inline, static, inherited] |
References Dune::ForLoopHelper::Apply< A, B >::apply().
static void Dune::ForLoopHelper::Apply< Operation< first > , GenericForLoop< ForLoopHelper::Apply, Operation, first+1, last > >::apply | ( | T1 & | p1, |
T2 & | p2, | ||
T3 & | p3, | ||
T4 & | p4 | ||
) | [inline, static, inherited] |
References Dune::ForLoopHelper::Apply< A, B >::apply().
static void Dune::ForLoopHelper::Apply< Operation< first > , GenericForLoop< ForLoopHelper::Apply, Operation, first+1, last > >::apply | ( | T1 & | p1, |
T2 & | p2, | ||
T3 & | p3 | ||
) | [inline, static, inherited] |
References Dune::ForLoopHelper::Apply< A, B >::apply().
static void Dune::ForLoopHelper::Apply< Operation< first > , GenericForLoop< ForLoopHelper::Apply, Operation, first+1, last > >::apply | ( | T1 & | p1, |
T2 & | p2 | ||
) | [inline, static, inherited] |
References Dune::ForLoopHelper::Apply< A, B >::apply().
static void Dune::ForLoopHelper::Apply< Operation< first > , GenericForLoop< ForLoopHelper::Apply, Operation, first+1, last > >::apply | ( | T1 & | p1 | ) | [inline, static, inherited] |
References Dune::ForLoopHelper::Apply< A, B >::apply().