Dune Core Modules (2.6.0)

apply.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_COMMON_STD_APPLY_HH
4#define DUNE_COMMON_STD_APPLY_HH
5
6#if DUNE_HAVE_CXX_APPLY
7 #include <tuple>
8#elif DUNE_HAVE_CXX_EXPERIMENTAL_APPLY
9 #include <experimental/tuple>
10#else
11 #include <cstddef>
12 #include <utility>
13 #include <tuple>
14#endif
15
16
17
18namespace Dune
19{
20
21 namespace Std
22 {
23
24#if DUNE_HAVE_CXX_APPLY
25
26 using std::apply;
27
28#elif DUNE_HAVE_CXX_EXPERIMENTAL_APPLY
29
31
32#else
33
34#ifndef DOXYGEN
35
36 namespace Impl
37 {
38 template<class F, class ArgTuple, std::size_t... i>
39 decltype(auto) applyHelper(F&& f, ArgTuple&& args, std::index_sequence<i...>)
40 {
41 return f(std::get<i>(args)...);
42 }
43 } // namespace Impl
44
45#endif // DOXYGEN
46
57 template<class F, class ArgTuple>
58 decltype(auto) apply(F&& f, ArgTuple&& args)
59 {
60 auto indices = std::make_index_sequence<std::tuple_size<std::decay_t<ArgTuple>>::value>();
61 return Impl::applyHelper(std::forward<F>(f), std::forward<ArgTuple>(args), indices);
62 }
63
64#endif
65
66 } // namespace Std
67} // namespace Dune
68
69#endif // #ifndef DUNE_COMMON_STD_APPLY_HH
decltype(auto) apply(F &&f, ArgTuple &&args)
Apply function with arguments given as tuple.
Definition: apply.hh:58
Dune namespace.
Definition: alignedallocator.hh:10
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Jul 15, 22:36, 2024)