forward.hpp
Go to the documentation of this file.
1 // Copyright (C) 2020-2024 Jonathan Müller and lexy contributors
2 // SPDX-License-Identifier: BSL-1.0
3 
4 #ifndef LEXY_CALLBACK_FORWARD_HPP_INCLUDED
5 #define LEXY_CALLBACK_FORWARD_HPP_INCLUDED
6 
7 #include <lexy/callback/base.hpp>
8 
9 namespace lexy
10 {
11 struct nullopt;
12 
13 template <typename T>
14 struct _fwd
15 {
16  using return_type = T;
17 
18  constexpr T operator()(T&& t) const
19  {
20  return LEXY_MOV(t);
21  }
22  constexpr T operator()(const T& t) const
23  {
24  return t;
25  }
26 };
27 template <>
28 struct _fwd<void>
29 {
30  using return_type = void;
31 
32  template <typename... Args>
33  constexpr auto sink(const Args&...) const
34  {
35  // We don't need a separate type, forward itself can have the required functions.
36  return *this;
37  }
38 
39  constexpr void operator()() const {}
40  constexpr void operator()(const lexy::nullopt&) const {}
41 
42  constexpr void finish() && {}
43 };
44 
46 template <typename T>
47 constexpr auto forward = _fwd<T>{};
48 } // namespace lexy
49 
50 #endif // LEXY_CALLBACK_FORWARD_HPP_INCLUDED
51 
LEXY_MOV
#define LEXY_MOV(...)
Definition: config.hpp:29
base.hpp
lexy::forward
constexpr auto forward
A callback that just forwards an existing object.
Definition: forward.hpp:47
lexy::_fwd
Definition: forward.hpp:14
lexy::nullopt
Definition: option.hpp:25
lexy::_fwd< void >::sink
constexpr auto sink(const Args &...) const
Definition: forward.hpp:33
lexy
Definition: any_ref.hpp:12
detail::void
j template void())
Definition: json.hpp:4893
lexyd::nullopt
constexpr auto nullopt
Definition: option.hpp:50
lexy::_fwd::return_type
T return_type
Definition: forward.hpp:16
lexy::_fwd< void >::operator()
constexpr void operator()() const
Definition: forward.hpp:39
lexy::_fwd::operator()
constexpr T operator()(T &&t) const
Definition: forward.hpp:18
lexy::_fwd< void >::return_type
void return_type
Definition: forward.hpp:30
lexy::_fwd< void >::finish
constexpr void finish() &&
Definition: forward.hpp:42
lexy::_fwd::operator()
constexpr T operator()(const T &t) const
Definition: forward.hpp:22
lexy::_fwd< void >::operator()
constexpr void operator()(const lexy::nullopt &) const
Definition: forward.hpp:40


behaviortree_cpp_v4
Author(s): Davide Faconti
autogenerated on Fri Dec 13 2024 03:19:16