dune-common  2.5.0
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 
11 
16 namespace Dune
17 {
18 
65  template< template< int > class Operation, int first, int last >
66  struct ForLoop
67  {
68  static_assert( (first <= last), "ForLoop: first > last" );
69 
70  template<typename... Args>
71  static void apply(Args&&... args)
72  {
74  [&](auto i){Operation<i+first>::apply(args...);});
75  }
76  };
77 
78 }
79 
80 #endif // #ifndef DUNE_COMMON_FORLOOP_HH
decltype(auto) apply(F &&f, ArgTuple &&args)
Apply function with arguments given as tuple.
Definition: apply.hh:54
Dune namespace.
Definition: alignment.hh:10
A static loop using TMP.
Definition: forloop.hh:66
static void apply(Args &&... args)
Definition: forloop.hh:71
constexpr void forEach(Range &&range, F &&f)
Range based for loop.
Definition: hybridutilities.hh:314
make_integer_sequence< std::size_t, n > make_index_sequence
Definition: utility.hh:80