dune-functions  2.6-dev
staticforloop.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 #ifndef DUNE_FUNCTIONS_COMMON_STATICFORLOOP_HH
4 #define DUNE_FUNCTIONS_COMMON_STATICFORLOOP_HH
5 
6 
7 #include <dune/common/concept.hh>
8 
11 
12 
13 namespace Dune {
14 namespace Functions {
15 
16 namespace Imp {
17 
18 template<class ST, ST begin, ST end>
19 struct StaticFindInRange
20 {
21  template<class F, class...Args>
22  static void apply(F&& f, Args&&... args)
23  {
24  if (f(std::integral_constant<ST, begin>(), std::forward<Args>(args)...))
25  return;
26  StaticFindInRange<ST, begin+1, end>::apply(std::forward<F>(f), std::forward<Args>(args)...);
27  }
28 };
29 
30 template<class ST, ST end>
31 struct StaticFindInRange<ST, end, end>
32 {
33  template<class F, class...Args>
34  static void apply(F&& f, Args&&...)
35  {}
36 };
37 
38 } //end namespace Imp
39 
40 
41 
55 template<std::size_t begin_t, std::size_t end_t, class F, class... Args>
56 void staticFindInRange(F&& f, Args&&... args)
57 {
58  Imp::StaticFindInRange<std::size_t, begin_t, end_t>::apply(std::forward<F>(f), std::forward<Args>(args)...);
59 }
60 
61 
62 } // namespace Dune::Functions
63 } // namespace Dune
64 
65 
66 
67 #endif //DUNE_FUNCTIONS_COMMON_STATICFORLOOP_HH
Dune
Definition: polynomial.hh:7
concepts.hh
Dune::Functions::staticFindInRange
void staticFindInRange(F &&f, Args &&... args)
Static find loop.
Definition: staticforloop.hh:56
type_traits.hh