invoke.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_DETAIL_INVOKE_HPP_INCLUDED
5 #define LEXY_DETAIL_INVOKE_HPP_INCLUDED
6 
8 
9 namespace lexy::_detail
10 {
11 template <typename MemberPtr, bool = std::is_member_object_pointer_v<MemberPtr>>
12 struct _mem_invoker;
13 template <typename R, typename ClassT>
14 struct _mem_invoker<R ClassT::*, true>
15 {
16  static constexpr decltype(auto) invoke(R ClassT::*f, ClassT& object)
17  {
18  return object.*f;
19  }
20  static constexpr decltype(auto) invoke(R ClassT::*f, const ClassT& object)
21  {
22  return object.*f;
23  }
24 
25  template <typename Ptr>
26  static constexpr auto invoke(R ClassT::*f, Ptr&& ptr) -> decltype((*LEXY_FWD(ptr)).*f)
27  {
28  return (*LEXY_FWD(ptr)).*f;
29  }
30 };
31 template <typename F, typename ClassT>
32 struct _mem_invoker<F ClassT::*, false>
33 {
34  template <typename ObjectT, typename... Args>
35  static constexpr auto _invoke(int, F ClassT::*f, ObjectT&& object, Args&&... args)
36  -> decltype((LEXY_FWD(object).*f)(LEXY_FWD(args)...))
37  {
38  return (LEXY_FWD(object).*f)(LEXY_FWD(args)...);
39  }
40  template <typename PtrT, typename... Args>
41  static constexpr auto _invoke(short, F ClassT::*f, PtrT&& ptr, Args&&... args)
42  -> decltype(((*LEXY_FWD(ptr)).*f)(LEXY_FWD(args)...))
43  {
44  return ((*LEXY_FWD(ptr)).*f)(LEXY_FWD(args)...);
45  }
46 
47  template <typename... Args>
48  static constexpr auto invoke(F ClassT::*f, Args&&... args)
49  -> decltype(_invoke(0, f, LEXY_FWD(args)...))
50  {
51  return _invoke(0, f, LEXY_FWD(args)...);
52  }
53 };
54 
55 template <typename ClassT, typename F, typename... Args>
56 constexpr auto invoke(F ClassT::*f, Args&&... args)
57  -> decltype(_mem_invoker<F ClassT::*>::invoke(f, LEXY_FWD(args)...))
58 {
60 }
61 
62 template <typename F, typename... Args>
63 constexpr auto invoke(F&& f, Args&&... args) -> decltype(LEXY_FWD(f)(LEXY_FWD(args)...))
64 {
65  return LEXY_FWD(f)(LEXY_FWD(args)...);
66 }
67 } // namespace lexy::_detail
68 
69 #endif // LEXY_DETAIL_INVOKE_HPP_INCLUDED
70 
lexy::_detail::_mem_invoker< F ClassT::*, false >::_invoke
static constexpr auto _invoke(int, F ClassT::*f, ObjectT &&object, Args &&... args) -> decltype((LEXY_FWD(object).*f)(LEXY_FWD(args)...))
Definition: invoke.hpp:35
config.hpp
LEXY_FWD
#define LEXY_FWD(...)
Definition: config.hpp:30
lexy::_detail::_mem_invoker< F ClassT::*, false >::_invoke
static constexpr auto _invoke(short, F ClassT::*f, PtrT &&ptr, Args &&... args) -> decltype(((*LEXY_FWD(ptr)).*f)(LEXY_FWD(args)...))
Definition: invoke.hpp:41
lexy::_detail::_mem_invoker< R ClassT::*, true >::invoke
static constexpr auto invoke(R ClassT::*f, Ptr &&ptr) -> decltype((*LEXY_FWD(ptr)).*f)
Definition: invoke.hpp:26
lexy::_detail::invoke
constexpr auto invoke(F &&f, Args &&... args) -> decltype(LEXY_FWD(f)(LEXY_FWD(args)...))
Definition: invoke.hpp:63
lexy::_detail::invoke
constexpr auto invoke(F ClassT::*f, Args &&... args) -> decltype(_mem_invoker< F ClassT::* >::invoke(f, LEXY_FWD(args)...))
Definition: invoke.hpp:56
f
static FILE * f
Definition: minitrace.cpp:74
lexy::_detail
Definition: any_ref.hpp:12
lexy::_detail::_mem_invoker
Definition: invoke.hpp:12
lexy::_detail::_mem_invoker< F ClassT::*, false >::invoke
static constexpr auto invoke(F ClassT::*f, Args &&... args) -> decltype(_invoke(0, f, LEXY_FWD(args)...))
Definition: invoke.hpp:48


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