Dune Core Modules (2.8.0)

staticforloop.hh
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
8
9#include <dune/functions/common/type_traits.hh>
10#include <dune/functions/functionspacebases/concepts.hh>
11
12
13namespace Dune {
14namespace Functions {
15
16namespace Imp {
17
18template<class ST, ST begin, ST end>
19struct 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
30template<class ST, ST end>
31struct 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
55template<std::size_t begin_t, std::size_t end_t, class F, class... Args>
56void 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
Infrastructure for concepts.
void staticFindInRange(F &&f, Args &&... args)
Static find loop.
Definition: staticforloop.hh:56
Dune namespace.
Definition: alignedallocator.hh:11
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 22, 23:33, 2024)