halcheck 1.0
Loading...
Searching...
No Matches
invoke.hpp
1#ifndef HALCHECK_LIB_FUNCTIONAL_INVOKE_HPP
2#define HALCHECK_LIB_FUNCTIONAL_INVOKE_HPP
3
4// IWYU pragma: private, include <halcheck/lib/functional.hpp>
5
6#include <halcheck/lib/pp.hpp>
7#include <halcheck/lib/type_traits.hpp>
8
9namespace halcheck { namespace lib {
10
23 template<typename F, typename... Args, HALCHECK_REQUIRE(std::is_member_pointer<lib::decay_t<F>>())>
24 auto operator()(F &&f, Args &&...args) const noexcept(noexcept(std::mem_fn(f)(std::forward<Args>(args)...)))
25 -> decltype(std::mem_fn(f)(std::forward<Args>(args)...)) {
26 return std::mem_fn(f)(std::forward<Args>(args)...);
27 }
28
29 template<typename F, typename... Args, HALCHECK_REQUIRE(!std::is_member_pointer<lib::decay_t<F>>())>
30 auto operator()(F &&f, Args &&...args) const noexcept(noexcept(std::forward<F>(f)(std::forward<Args>(args)...)))
31 -> decltype(std::forward<F>(f)(std::forward<Args>(args)...)) {
32 return std::forward<F>(f)(std::forward<Args>(args)...);
33 }
35
41template<typename F, typename... Args>
43
45template<typename R, typename F, typename... Args>
46using invocable_r = lib::convertible<lib::invoke_result_t<F, Args...>, R>;
47
53template<typename R, typename F, typename... Args>
54struct is_invocable_r : lib::is_detected<lib::invocable_r, R, F, Args...> {};
55
57template<typename F, typename... Args>
58using invocable = lib::invoke_result_t<F, Args...>;
59
65template<typename F, typename... Args>
66struct is_invocable : lib::is_detected<lib::invocable, F, Args...> {};
67
69template<typename F, typename... Args>
71
77template<typename F, typename... Args>
78struct is_nothrow_invocable : lib::is_detected<lib::nothrow_invocable, F, Args...> {};
79
81template<typename R, typename F, typename... Args>
82using nothrow_invocable_r = lib::void_t<lib::invocable_r<R, F, Args...>, lib::nothrow_invocable<F, Args...>>;
83
89template<typename R, typename F, typename... Args>
90struct is_nothrow_invocable_r : lib::is_detected<lib::nothrow_invocable_r, R, F, Args...> {};
91
92}} // namespace halcheck::lib
93
94#endif
T declval(T... args)
T forward(T... args)
HALCHECK_INLINE_CONSTEXPR struct halcheck::lib::@20 invoke
An implementation of std::invoke.
decltype(lib::invoke(std::declval< F >(), std::declval< Args >()...)) invoke_result_t
An implementation of std::invoke_result_t.
Definition invoke.hpp:42
#define HALCHECK_INLINE_CONSTEXPR
A backwards-compatible substitute for inline constexpr.
Definition pp.hpp:70
typename std::decay< T >::type decay_t
An implementation of std::decay_t.
Definition type_traits.hpp:101
typename std::enable_if< Cond, T >::type enable_if_t
An implementation of std::enable_if_t.
Definition type_traits.hpp:93
void void_t
An implementation of std::void_t.
Definition type_traits.hpp:43
#define HALCHECK_REQUIRE(...)
Expands to a template argument that is only valid if the given argument evaluates to true.
Definition type_traits.hpp:24
T mem_fn(T... args)
An implementation of std::experimental::is_detected.
Definition type_traits.hpp:247
An implementation of std::is_invocable_r.
Definition invoke.hpp:54
An implementation of std::is_invocable.
Definition invoke.hpp:66
An implementation of std::is_nothrow_invocable_r.
Definition invoke.hpp:90
An implementation of std::is_nothrow_invocable.
Definition invoke.hpp:78