VCCC  2024.05
VisualCamp Common C++ library
invocable.hpp
Go to the documentation of this file.
1 //
2 // Created by cosge on 2023-12-27.
3 //
4 
5 #ifndef VCCC_CONCEPTS_INVOCABLE_HPP
6 #define VCCC_CONCEPTS_INVOCABLE_HPP
7 
8 #include <cstddef>
9 #include <type_traits>
10 
14 
15 namespace vccc {
16 namespace detail {
17 
18 template<typename F, typename Seq, typename = void>
19 struct explicit_invocable : std::false_type {};
20 
21 template<typename F, typename... Args>
22 struct explicit_invocable<
23  F, type_sequence<Args...>,
24  void_t<decltype(
25  vccc::invoke(
26  std::declval<decltype( std::forward<F> (std::declval<F&&> ()) )>(),
27  std::declval<decltype( std::forward<Args>(std::declval<Args&&>()) )>()...
28  )
29  )>
30  > : std::true_type {};
31 
32 template<typename F, typename Seq>
33 struct invocable_impl : std::false_type {};
34 
35 template<typename F, typename... Args>
36 struct invocable_impl<F, type_sequence<Args...>> : explicit_invocable<F, type_sequence<Args...>> {};
37 
38 } // namespace detail
39 
42 
51 template<typename F, typename... Args>
52 struct invocable : detail::invocable_impl<F, type_sequence<Args...>> {};
53 
63 template<typename F, typename... Args >
64 struct regular_invocable : invocable<F, Args...> {};
65 
67 
68 } // namespace vccc
69 
70 #endif // VCCC_CONCEPTS_INVOCABLE_HPP
constexpr invoke_result_t< F, Args... > invoke(F &&f, Args &&... args) noexcept(is_nothrow_invocable< F, Args... >::value)
Definition: invoke.hpp:38
void void_t
Definition: void_t.hpp:19
Definition: directory.h:12
specifies that a callable type can be invoked with a given set of argument types
Definition: invocable.hpp:52
specifies that a callable type can be invoked with a given set of argument types
Definition: invocable.hpp:64