callback/integer.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_INTEGER_HPP_INCLUDED
5 #define LEXY_CALLBACK_INTEGER_HPP_INCLUDED
6 
7 #include <lexy/callback/base.hpp>
8 #include <lexy/dsl/sign.hpp>
9 
10 namespace lexy
11 {
12 template <typename T>
13 struct _int
14 {
15  using return_type = T;
16 
17  // You don't actually produce an integer value.
18  constexpr T operator()(lexy::plus_sign) const = delete;
19  constexpr T operator()(lexy::minus_sign) const = delete;
20 
21  template <typename Integer>
22  constexpr T operator()(const Integer& value) const
23  {
24  return T(value);
25  }
26  template <typename Integer>
27  constexpr T operator()(lexy::plus_sign, const Integer& value) const
28  {
29  return T(value);
30  }
31  template <typename Integer>
32  constexpr T operator()(lexy::minus_sign, const Integer& value) const
33  {
34  return T(-value);
35  }
36 };
37 
38 // A callback that takes an optional sign and an integer and produces the signed integer.
39 template <typename T>
40 constexpr auto as_integer = _int<T>{};
41 } // namespace lexy
42 
43 #endif // LEXY_CALLBACK_INTEGER_HPP_INCLUDED
44 
base.hpp
sign.hpp
lexy::_int::return_type
T return_type
Definition: callback/integer.hpp:15
lexy::_int::operator()
constexpr T operator()(lexy::plus_sign, const Integer &value) const
Definition: callback/integer.hpp:27
lexy::plus_sign
Definition: sign.hpp:24
lexy
Definition: any_ref.hpp:12
lexy::_int::operator()
constexpr T operator()(lexy::plus_sign) const =delete
lexy::as_integer
constexpr auto as_integer
Definition: callback/integer.hpp:40
lexy::_int::operator()
constexpr T operator()(lexy::minus_sign, const Integer &value) const
Definition: callback/integer.hpp:32
lexy::_int
Definition: callback/integer.hpp:13
lexy::_int::operator()
constexpr T operator()(const Integer &value) const
Definition: callback/integer.hpp:22
lexy::minus_sign
Definition: sign.hpp:26


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