Dune Core Modules (2.3.1)
A static loop using TMP. More...
#include <dune/common/forloop.hh>
Detailed Description
class Dune::ForLoop< Operation, first, last >
A static loop using TMP.
The ForLoop takes a
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:
- Note
- Don't use any rvalues as the arguments to apply().
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"));
The documentation for this class was generated from the following file:
- dune/common/forloop.hh