dune-functions 2.9.0
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
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
void staticFindInRange(F &&f, Args &&... args)
Static find loop.
Definition: staticforloop.hh:56
Definition: polynomial.hh:10