8#ifndef INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_TYPE_TRAITS_IS_INVOCABLE_HPP_
9#define INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_TYPE_TRAITS_IS_INVOCABLE_HPP_
15#include "arene/base/stdlib_choice/cstddef.hpp"
16#include "arene/base/stdlib_choice/declval.hpp"
17#include "arene/base/stdlib_choice/enable_if.hpp"
18#include "arene/base/stdlib_choice/integral_constant.hpp"
19#include "arene/base/stdlib_choice/is_convertible.hpp"
20#include "arene/base/stdlib_choice/is_same.hpp"
21#include "arene/base/stdlib_choice/is_void.hpp"
22#include "arene/base/stdlib_choice/remove_cv.hpp"
23#include "arene/base/stdlib_choice/remove_reference.hpp"
31namespace is_invocable_detail {
35struct invalid_return {};
42template <
typename Fn,
typename... Args>
43class is_invocable_impl {
51 template <
typename MemFuncPtr,
typename Instance,
typename... Params>
61 template <
typename MemPtr,
typename Instance>
70 template <
typename MemFuncPtr,
typename Pointer,
typename... Params>
80 template <
typename MemPtr,
typename Po
inter>
116 template <
typename Callable,
typename... Params>
123 template <
typename...>
124 static auto try_invoke(
void* dummy) -> invalid_return;
127 using result =
decltype(is_invocable_impl::try_invoke<Fn, Args...>(
nullptr));
131 static constexpr bool is_noexcept{
noexcept(is_invocable_impl::try_invoke<Fn, Args...>(
nullptr))};
142template <
bool RequireNoThrow,
typename Ret,
typename Fn,
typename... Args>
143struct is_invocable_r final {
145 using invoke_detail = is_invocable_impl<Fn, Args...>;
148 static constexpr bool noexcept_ok{!RequireNoThrow || invoke_detail::is_noexcept};
154 static constexpr bool return_ok{
159 static constexpr bool value{noexcept_ok && return_valid && return_ok};
170template <
typename Fn,
typename Args,
typename = constra
ints<>>
171class invoke_result {};
181template <
typename Fn,
typename... Args>
186 std::
enable_if_t<!std::is_same<invalid_return, typename is_invocable_impl<Fn, Args...>::result>::value>>> {
189 using type =
typename is_invocable_impl<Fn, Args...>::result;
199template <
typename Fn,
typename... Args>
201 :
public std::integral_constant<bool, is_invocable_detail::is_invocable_r<false, void, Fn, Args...>::value> {};
207template <
typename Fn,
typename... Args>
214template <
typename Ret,
typename Fn,
typename... Args>
216 :
public std::integral_constant<bool, is_invocable_detail::is_invocable_r<false, Ret, Fn, Args...>::value> {};
223template <
typename Ret,
typename Fn,
typename... Args>
230template <
typename Fn,
typename... Args>
232 :
public std::integral_constant<bool, is_invocable_detail::is_invocable_r<true, void, Fn, Args...>::value> {};
238template <
typename Fn,
typename... Args>
246template <
typename Ret,
typename Fn,
typename... Args>
248 :
public std::integral_constant<bool, is_invocable_detail::is_invocable_r<true, Ret, Fn, Args...>::value> {};
255template <
typename Ret,
typename Fn,
typename... Args>
262template <
typename Fn,
typename... Args>
263class invoke_result :
public is_invocable_detail::invoke_result<Fn, type_list<Args...>> {};
270template <
typename Fn,
typename... Args>
Determines the return type of a functor invoked with the specified arguments.
Definition is_invocable.hpp:263
Determine if a functor type is invocable with the specified return and argument types.
Definition is_invocable.hpp:216
Determine if a functor type is invocable with the specified argument types.
Definition is_invocable.hpp:201
Determine if a functor type is no-throw invocable with the specified return and argument types.
Definition is_invocable.hpp:248
Determine if a functor type is no-throw invocable with the specified argument types.
Definition is_invocable.hpp:232
A helper class to represent a compile-time constant with the specified type and value....
Definition integral_constant.hpp:23
static constexpr value_type value
Definition integral_constant.hpp:34
Definition accumulate.hpp:37
constexpr bool is_invocable_v
Determine if a functor type is invocable with the specified argument types.
constexpr bool is_invocable_r_v
Determine if a functor type is invocable with the specified return and argument types.
typename invoke_result< Fn, Args... >::type invoke_result_t
The return type of a functor invoked with the specified arguments.
Definition is_invocable.hpp:271
constexpr bool is_nothrow_invocable_r_v
Determine if a functor type is no-throw invocable with the specified return and argument types.
constexpr bool is_nothrow_invocable_v
Determine if a functor type is no-throw invocable with the specified argument types.
typename constraints_impl::constraints< EnableIfs... >::type constraints
Helper used to express template constraints in a consistent way using std::enable_if_t.
Definition constraints.hpp:51
Definition accumulate.hpp:36
typedef nullptr_t
The type of nullptr.
Definition cstddef.hpp:33
typename enable_if< Condition, Type >::type enable_if_t
Type alias to support constraining templates. Is an alias for the specified type if the Condition is ...
Definition enable_if.hpp:41
auto declval() noexcept -> T &&
A dummy function that is declared but not defined, with a user-specified return type,...