DUNE PDELab (git)

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
4// SPDX-FileCopyrightText: Copyright © DUNE Project contributors, see file AUTHORS.md
5// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception OR LGPL-3.0-or-later
6
7#ifndef DUNE_FUNCTIONS_COMMON_STATICFORLOOP_HH
8#define DUNE_FUNCTIONS_COMMON_STATICFORLOOP_HH
9
10
12
13#include <dune/functions/common/type_traits.hh>
14#include <dune/functions/functionspacebases/concepts.hh>
15
16
17namespace Dune {
18namespace Functions {
19
20namespace Imp {
21
22template<class ST, ST begin, ST end>
23struct StaticFindInRange
24{
25 template<class F, class...Args>
26 static void apply(F&& f, Args&&... args)
27 {
28 if (f(std::integral_constant<ST, begin>(), std::forward<Args>(args)...))
29 return;
30 StaticFindInRange<ST, begin+1, end>::apply(std::forward<F>(f), std::forward<Args>(args)...);
31 }
32};
33
34template<class ST, ST end>
35struct StaticFindInRange<ST, end, end>
36{
37 template<class F, class...Args>
38 static void apply(F&& f, Args&&...)
39 {}
40};
41
42} //end namespace Imp
43
44
45
59template<std::size_t begin_t, std::size_t end_t, class F, class... Args>
60void staticFindInRange(F&& f, Args&&... args)
61{
62 Imp::StaticFindInRange<std::size_t, begin_t, end_t>::apply(std::forward<F>(f), std::forward<Args>(args)...);
63}
64
65
66} // namespace Dune::Functions
67} // namespace Dune
68
69
70
71#endif //DUNE_FUNCTIONS_COMMON_STATICFORLOOP_HH
Infrastructure for concepts.
void staticFindInRange(F &&f, Args &&... args)
Static find loop.
Definition: staticforloop.hh:60
Dune namespace.
Definition: alignedallocator.hh:13
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 13, 23:29, 2024)