20 #ifndef __utl_utility_invoke_h__ 21 #define __utl_utility_invoke_h__ 26 #include <type_traits> 45 template <
class T,
class Type,
class T1,
class... Args,
47 std::is_member_function_pointer<std::decay_t<Type T::*>>::value &&
48 std::is_base_of<T, std::decay_t<T1>>::value,
51 decltype(
auto)
invoke_impl_(Type T::* f, T1&& t1, Args&&... args) {
52 return (std::forward<T1>(t1).*f)(std::forward<Args>(args)...);
56 template <
class T,
class Type,
class T1,
class... Args,
58 std::is_member_function_pointer<std::decay_t<Type T::*>>::value &&
59 is_ref_wrapper<std::decay_t<T1>>::value,
62 decltype(
auto)
invoke_impl_(Type T::* f, T1&& t1, Args&&... args) {
63 return (t1.get().*f)(std::forward<Args>(args)...);
67 template <
class T,
class Type,
class T1,
class... Args,
69 std::is_member_function_pointer<std::decay_t<Type T::*>>::value &&
70 !std::is_base_of<T, std::decay_t<T1>>::value &&
71 !is_ref_wrapper<std::decay_t<T1>>::value,
74 decltype(
auto)
invoke_impl_(Type T::* f, T1&& t1, Args&&... args) {
75 return ((*std::forward<T1>(t1)).*f)(std::forward<Args>(args)...);
79 template <
class T,
class Type,
class T1,
class... Args,
81 std::is_member_object_pointer<std::decay_t<Type T::*>>::value &&
82 std::is_base_of<T, std::decay_t<T1>>::value,
85 decltype(
auto)
invoke_impl_(Type T::* f, T1&& t1, Args&&... args) {
86 return std::forward<T1>(t1).*f;
90 template <
class T,
class Type,
class T1,
class... Args,
92 std::is_member_object_pointer<std::decay_t<Type T::*>>::value &&
93 is_ref_wrapper<std::decay_t<T1>>::value,
96 decltype(
auto)
invoke_impl_(Type T::* f, T1&& t1, Args&&... args) {
101 template <
class T,
class Type,
class T1,
class... Args,
103 std::is_member_object_pointer<std::decay_t<Type T::*>>::value &&
104 !std::is_base_of<T, std::decay_t<T1>>::value &&
105 !is_ref_wrapper<std::decay_t<T1>>::value,
108 decltype(
auto)
invoke_impl_(Type T::* f, T1&& t1, Args&&... args) {
109 return (*std::forward<T1>(t1)).*f;
112 template <
class F,
class... Args>
114 return std::forward<F>(f)(std::forward<Args>(args)...);
120 template<
typename _Callable,
typename... _Args>
121 inline decltype(
auto)
invoke(_Callable&& fn, _Args&&... args) {
123 std::forward<_Callable>(fn), std::forward<_Args>(args)...
129 template <
typename F,
typename... Args>
131 std::is_constructible<
132 std::function<void(Args ...)>,
133 std::reference_wrapper<typename std::remove_reference<F>::type>
137 template <
typename R,
typename F,
typename... Args>
139 std::is_constructible<
140 std::function<R(Args ...)>,
141 std::reference_wrapper<typename std::remove_reference<F>::type>
149 template<
typename _Callable,
typename... _Args>
151 using type = decltype (
156 template<
bool B,
typename _Callable,
typename... _Args>
161 template <
typename _Callable,
typename... _Args>
169 template <
typename _Callable,
typename... _Args>
177 template<
typename _Callable,
typename... _Args>
decltype(auto) invoke_impl_(Type T::*f, T1 &&t1, Args &&... args)
decltype(auto) invoke(_Callable &&fn, _Args &&... args)
Invoke a callable object (for C++14)
meta::invoke_t< meta::quote< try_invoke >, _Callable, _Args... > type
STL's core language concepts.
meta::eval< invoke_result< _Callable, _Args... > > invoke_result_t
invoke_result_t (for C++14)
std::is_invocable_r trait for C++11
decltype(detail::invoke_impl_(std::declval< _Callable && >(), std::declval< _Args && >()...)) type
Implementation detail main forward header.
std::is_invocable trait for C++11