Reference documentation for deal.II version 9.6.0
\(\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: 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// Part of the source code is dual licensed under Apache-2.0 WITH
9// LLVM-exception OR LGPL-2.1-or-later. Detailed license information
10// governing the source code and code contributions can be found in
11// LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II.
12//
13// ------------------------------------------------------------------------
14#ifndef dealii_cxx20_functional_h
15#define dealii_cxx20_functional_h
16
17#include <deal.II/base/config.h>
18
19#ifdef DEAL_II_HAVE_CXX20
20# include <functional>
21#else
22# include <functional>
23# include <tuple>
24# include <utility>
25#endif
26
28
29namespace std_cxx20
30{
31#ifndef DEAL_II_HAVE_CXX20
32# ifndef DOXYGEN
33
34 namespace internal
35 {
41 template <typename F,
42 size_t... Ind,
43 typename BoundArgsTuple,
44 typename... CallArgs>
45 constexpr decltype(auto)
46 call_bind(F &&function,
47 std::index_sequence<Ind...>,
48 BoundArgsTuple &&bound_args,
49 CallArgs &&...call_args)
50 {
51 return std::invoke(std::forward<F>(function),
52 std::get<Ind>(
53 std::forward<BoundArgsTuple>(bound_args))...,
54 std::forward<CallArgs>(call_args)...);
55 }
56
61 template <typename F, typename... BoundArgs>
62 decltype(auto)
63 make_bind_front(F &&f, BoundArgs &&...bound_args)
64 {
65 return [f = std::forward<F>(f),
66 bound_args = std::make_tuple(
67 std::forward<BoundArgs>(bound_args)...)](auto &&...call_args) {
68 // Perform actual call inside a helper functions which allows to use
69 // pattern-matching to the index sequence.
70 return call_bind(f,
71 std::index_sequence_for<BoundArgs...>{},
72 bound_args,
73 std::forward<decltype(call_args)>(call_args)...);
74 };
75 }
76
77 } // namespace internal
78
79# endif
80
119 template <typename F, typename... BoundArgs>
120 decltype(auto)
121 bind_front(F &&f, BoundArgs &&...bound_args)
122 {
123 return internal::make_bind_front(std::forward<F>(f),
124 std::forward<BoundArgs>(bound_args)...);
125 }
126#else
127 using std::bind_front;
128#endif
129
130} // namespace std_cxx20
131
133
134#endif
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:503
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:504
Tensor< 2, dim, Number > F(const Tensor< 2, dim, Number > &Grad_u)
decltype(auto) bind_front(F &&f, BoundArgs &&...bound_args)
Definition functional.h:121