Dune Core Modules (2.4.1)

forloop.hh
Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2// vi: set et ts=4 sw=2 sts=2:
3
4#ifndef DUNE_COMMON_FORLOOP_HH
5#define DUNE_COMMON_FORLOOP_HH
6
7#include <utility>
8
13namespace Dune
14{
15
16#ifndef DOXYGEN
17 // GenericForLoop
18 // --------------
19
20 template< template< class, class > class Operation, template< int > class Value, int first, int last >
21 class GenericForLoop
22 : public Operation< Value< first >, GenericForLoop< Operation, Value, first+1, last > >
23 {
24 static_assert( (first <= last), "GenericForLoop: first > last" );
25 };
26
27 template< template< class, class > class Operation, template< int > class Value, int last >
28 class GenericForLoop< Operation, Value, last, last >
29 : public Value< last >
30 {};
31
32 // ForLoopHelper
33 // -------------
34
35 namespace ForLoopHelper
36 {
37
38 template< class A, class B >
39 struct Apply
40 {
41
42 template< typename... Params >
43 static void apply ( Params&&... params )
44 {
45 A::apply( std::forward<Params>(params)... );
46 B::apply( std::forward<Params>(params)... );
47 }
48
49 };
50
51 } // end namespace ForLoopHelper
52
53#endif
54
55
107 template< template< int > class Operation, int first, int last >
109 : public GenericForLoop< ForLoopHelper::Apply, Operation, first, last >
110 {
111 static_assert( (first <= last), "ForLoop: first > last" );
112 };
113
114}
115
116#endif // #ifndef DUNE_COMMON_FORLOOP_HH
A static loop using TMP.
Definition: forloop.hh:110
Dune namespace.
Definition: alignment.hh:10
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 21, 23:30, 2024)