deal.II version GIT relicensing-6809-ge913b9bb34 2026-09-25 17:20:01+00:00
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
Loading...
Searching...
No Matches
functional.h
Go to the documentation of this file.
1// -----------------------------------------------------------------------------
2//
3// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception OR LGPL-2.1-or-later
4// Copyright (C) 2023 by the deal.II authors
5//
6// This file is part of the deal.II library.
7//
8// Detailed license information governing the source code and contributions
9// can be found in LICENSE.md and CONTRIBUTING.md at the top level directory.
10//
11// -----------------------------------------------------------------------------
12#ifndef dealii_cxx20_functional_h
13#define dealii_cxx20_functional_h
14
15#include <deal.II/base/config.h>
16
17#ifdef DEAL_II_HAVE_CXX20
18# include <functional>
19#else
20# include <functional>
21# include <tuple>
22# include <utility>
23#endif
24
26
27namespace std_cxx20
28{
29#ifndef DEAL_II_HAVE_CXX20
30# ifndef DOXYGEN
31
32 namespace internal
33 {
39 template <typename F,
40 size_t... Ind,
41 typename BoundArgsTuple,
42 typename... CallArgs>
43 constexpr decltype(auto)
44 call_bind(F &&function,
45 std::index_sequence<Ind...>,
46 BoundArgsTuple &&bound_args,
47 CallArgs &&...call_args)
48 {
49 return std::invoke(std::forward<F>(function),
50 std::get<Ind>(
51 std::forward<BoundArgsTuple>(bound_args))...,
52 std::forward<CallArgs>(call_args)...);
53 }
54
59 template <typename F, typename... BoundArgs>
60 decltype(auto)
61 make_bind_front(F &&f, BoundArgs &&...bound_args)
62 {
63 return [f = std::forward<F>(f),
64 bound_args = std::make_tuple(
65 std::forward<BoundArgs>(bound_args)...)](auto &&...call_args) {
66 // Perform actual call inside a helper functions which allows to use
67 // pattern-matching to the index sequence.
68 return call_bind(f,
69 std::index_sequence_for<BoundArgs...>{},
70 bound_args,
71 std::forward<decltype(call_args)>(call_args)...);
72 };
73 }
74
75 } // namespace internal
76
77# endif
78
117 template <typename F, typename... BoundArgs>
118 decltype(auto)
119 bind_front(F &&f, BoundArgs &&...bound_args)
120 {
121 return internal::make_bind_front(std::forward<F>(f),
122 std::forward<BoundArgs>(bound_args)...);
123 }
124#else
125 using std::bind_front;
126#endif
127
128} // namespace std_cxx20
129
131
132#endif
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:38
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:39
Tensor< 2, dim, Number > F(const Tensor< 2, dim, Number > &Grad_u)
decltype(auto) bind_front(F &&f, BoundArgs &&...bound_args)
Definition functional.h:119