14 #ifndef RANGES_V3_FUNCTIONAL_INVOKE_HPP
15 #define RANGES_V3_FUNCTIONAL_INVOKE_HPP
18 #include <type_traits>
26 #include <range/v3/utility/static_const.hpp>
28 #include <range/v3/detail/prologue.hpp>
30 RANGES_DIAGNOSTIC_PUSH
31 RANGES_DIAGNOSTIC_IGNORE_CXX17_COMPAT
32 RANGES_DIAGNOSTIC_IGNORE_DEPRECATED_DECLARATIONS
34 #ifndef RANGES_CONSTEXPR_INVOKE
35 #ifdef RANGES_WORKAROUND_CLANG_23135
36 #define RANGES_CONSTEXPR_INVOKE 0
38 #define RANGES_CONSTEXPR_INVOKE 1
50 RANGES_DIAGNOSTIC_PUSH
51 RANGES_DIAGNOSTIC_IGNORE_VOID_PTR_DEREFERENCE
54 U & can_reference_(U &&);
60 CPP_requires(dereferenceable_part_,
63 detail::can_reference_(*(T &&) t)
68 CPP_concept dereferenceable_ =
69 CPP_requires_ref(detail::dereferenceable_part_, T);
75 RANGES_INLINE_VAR constexpr
bool is_reference_wrapper_v =
82 RANGES_INLINE_VAR constexpr
bool is_reference_wrapper_v =
83 detail::is_reference_wrapper_v<detail::decay_t<T>>;
90 using is_reference_wrapper_t RANGES_DEPRECATED(
97 template(
typename,
typename T1)(
98 requires detail::dereferenceable_<T1>)
99 static constexpr decltype(
auto)
coerce(T1 && t1,
long)
100 noexcept(noexcept(*
static_cast<T1 &&
>(t1)))
102 return *
static_cast<T1 &&
>(t1);
105 template(
typename T,
typename T1)(
106 requires derived_from<detail::decay_t<T1>, T>)
107 static constexpr T1 &&
coerce(T1 && t1,
int) noexcept
109 return static_cast<T1 &&
>(t1);
112 template(
typename,
typename T1)(
113 requires detail::is_reference_wrapper_v<detail::decay_t<T1>>)
114 static constexpr decltype(
auto)
coerce(T1 && t1,
int) noexcept
116 return static_cast<T1 &&
>(t1).get();
120 template<
typename F,
typename T,
typename T1,
typename... Args>
121 constexpr
auto operator()(F T::*f, T1&& t1, Args&&... args)
const
122 noexcept(noexcept((invoke_fn::coerce<T>((T1&&) t1, 0).*f)((Args&&) args...)))
123 -> decltype((invoke_fn::coerce<T>((T1&&) t1, 0).*f)((Args&&) args...))
125 return (invoke_fn::coerce<T>((T1&&) t1, 0).*f)((Args&&) args...);
128 template<
typename D,
typename T,
typename T1>
129 constexpr
auto operator()(D T::*f, T1&& t1)
const
130 noexcept(noexcept(invoke_fn::coerce<T>((T1&&) t1, 0).*f))
131 -> decltype(invoke_fn::coerce<T>((T1&&) t1, 0).*f)
133 return invoke_fn::coerce<T>((T1&&) t1, 0).*f;
136 template<
typename F,
typename... Args>
137 CPP_PP_IIF(RANGES_CONSTEXPR_INVOKE)(CPP_PP_EXPAND, CPP_PP_EAT)(constexpr)
138 auto operator()(F&& f, Args&&... args)
const
139 noexcept(noexcept(((F&&) f)((Args&&) args...)))
140 -> decltype(((F&&) f)((Args&&) args...))
142 return ((F&&) f)((Args&&) args...);
148 #ifdef RANGES_WORKAROUND_MSVC_701385
152 template<
typename Void,
typename Fun,
typename... Args>
153 struct _invoke_result_
156 template<
typename Fun,
typename... Args>
157 struct _invoke_result_<
158 meta::
void_<decltype(invoke(std::declval<Fun>(), std::declval<Args>()...))>,
161 using type = decltype(
invoke(std::declval<Fun>(), std::declval<Args>()...));
166 template<
typename Fun,
typename... Args>
167 using invoke_result = detail::_invoke_result_<void, Fun, Args...>;
169 template<
typename Fun,
typename... Args>
170 using invoke_result_t =
meta::_t<invoke_result<Fun, Args...>>;
173 template<
typename Fun,
typename... Args>
174 using invoke_result_t =
175 decltype(
invoke(std::declval<Fun>(), std::declval<Args>()...));
177 template<
typename Fun,
typename... Args>
185 template<
bool IsInvocable>
186 struct is_nothrow_invocable_impl_
188 template<
typename Fn,
typename... Args>
189 static constexpr
bool apply() noexcept
195 struct is_nothrow_invocable_impl_<true>
197 template<
typename Fn,
typename... Args>
198 static constexpr
bool apply() noexcept
200 return noexcept(
invoke(std::declval<Fn>(), std::declval<Args>()...));
206 template<
typename Fn,
typename... Args>
207 RANGES_INLINE_VAR constexpr
bool is_invocable_v =
208 meta::is_trait<invoke_result<Fn, Args...>>::value;
210 template<
typename Fn,
typename... Args>
211 RANGES_INLINE_VAR constexpr
bool is_nothrow_invocable_v =
212 detail::is_nothrow_invocable_impl_<is_invocable_v<Fn, Args...>>
::template apply<
216 template<
typename Sig>
217 struct RANGES_DEPRECATED(
218 "ranges::result_of
is deprecated. "
222 template<
typename Fun,
typename... Args>
223 struct RANGES_DEPRECATED(
224 "ranges::result_of
is deprecated. "
234 using ranges::invoke_result_t;
235 using ranges::is_invocable_v;
236 using ranges::is_nothrow_invocable_v;
242 RANGES_DIAGNOSTIC_POP
244 #include <range/v3/detail/epilogue.hpp>
template(typename ActionFn, typename Rng)(concept(invocable_action_closure_)(ActionFn
\concept invocable_action_closure_
RANGES_INLINE_VARIABLE(detail::to_container_fn< detail::from_range< std::vector >>, to_vector) template< template< typename... > class ContT > auto to(RANGES_HIDDEN_DETAIL(detail
For initializing a container of the specified type with the elements of an Range.
Definition: conversion.hpp:399
std::integral_constant< bool, B > bool_
An integral constant wrapper for bool.
Definition: meta.hpp:168
typename T::type _t
Type alias for T::type.
Definition: meta.hpp:141
_t< extension::apply< Fn, L > > apply
Applies the invocable Fn using the types in the type list L as arguments.
Definition: meta.hpp:1030
typename Fn::template invoke< Args... > invoke
Evaluate the invocable Fn with the arguments Args.
Definition: meta.hpp:541
_t< detail::is_< T, C > > is
is
Definition: meta.hpp:874
void void_
An alias for void.
Definition: meta.hpp:597
Definition: arithmetic.hpp:78
Definition: invoke.hpp:95
Definition: invoke.hpp:179