constant.hpp
Go to the documentation of this file.
1 // Copyright (C) 2020-2023 Jonathan Müller and lexy contributors
2 // SPDX-License-Identifier: BSL-1.0
3 
4 #ifndef LEXY_CALLBACK_CONSTANT_HPP_INCLUDED
5 #define LEXY_CALLBACK_CONSTANT_HPP_INCLUDED
6 
7 #include <lexy/callback/base.hpp>
8 
9 namespace lexy
10 {
11 template <typename T>
12 struct _constant
13 {
14  T _value;
15 
16  using return_type = T;
17 
18  constexpr const T& operator()() const
19  {
20  return _value;
21  }
22 };
23 
25 template <typename Arg>
26 LEXY_CONSTEVAL auto constant(Arg&& value)
27 {
28  return _constant<std::decay_t<Arg>>{LEXY_FWD(value)};
29 }
30 } // namespace lexy
31 
32 #endif // LEXY_CALLBACK_CONSTANT_HPP_INCLUDED
33 
lexy::_constant::operator()
constexpr const T & operator()() const
Definition: constant.hpp:18
lexy::_constant::_value
T _value
Definition: constant.hpp:14
LEXY_CONSTEVAL
#define LEXY_CONSTEVAL
Definition: config.hpp:90
base.hpp
LEXY_FWD
#define LEXY_FWD(...)
Definition: config.hpp:22
lexy::constant
LEXY_CONSTEVAL auto constant(Arg &&value)
Creates a callback that produces the given value without accepting arguments.
Definition: constant.hpp:26
lexy
Definition: any_ref.hpp:12
lexy::_constant
Definition: constant.hpp:12
lexy::_constant::return_type
T return_type
Definition: constant.hpp:16


behaviortree_cpp_v4
Author(s): Davide Faconti
autogenerated on Fri Jun 28 2024 02:20:07