3 @Copyright Barrett Adair 2015-2017
4 Distributed under the Boost Software License, Version 1.0.
5 (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
9 #ifndef BOOST_CLBL_TRTS_IS_INVOCABLE_HPP
10 #define BOOST_CLBL_TRTS_IS_INVOCABLE_HPP
12 #include <boost/callable_traits/detail/core.hpp>
13 #include <boost/callable_traits/detail/is_invocable_impl.hpp>
15 namespace boost { namespace callable_traits {
18 /*`[section:ref_is_invocable is_invocable]
20 ``#include <boost/callable_traits/is_invocable.hpp>``
24 // inherits from either std::true_type or std::false_type
25 template<typename T, typename... Args>
28 // inherits from either std::true_type or std::false_type
29 template<typename Ret, typename T, typename... Args>
30 struct is_invocable_r;
33 template<typename T, typename... Args>
34 struct is_invocable : detail::is_invocable_impl<T, Args...>::type {
35 using type = typename detail::is_invocable_impl<T, Args...>::type;
38 template<typename Ret, typename T, typename... Args>
40 : detail::is_invocable_r_impl<
41 typename detail::is_invocable_impl<T, Args...>::type, Ret, T, Args...>::type
43 using type = typename detail::is_invocable_r_impl<
44 typename detail::is_invocable_impl<T, Args...>::type, Ret, T, Args...>::type;
47 #ifdef BOOST_CLBL_TRTS_DISABLE_VARIABLE_TEMPLATES
49 template<typename T, typename... Args>
50 struct is_invocable_v {
51 static_assert(std::is_same<T, detail::dummy>::value,
52 "Variable templates not supported on this compiler.");
55 template<typename Ret, typename T, typename... Args>
56 struct is_invocable_r_v {
57 static_assert(std::is_same<T, detail::dummy>::value,
58 "Variable templates not supported on this compiler.");
63 // only available when variable templates are supported
64 template<typename T, typename... Args>
66 BOOST_CLBL_TRAITS_INLINE_VAR
68 constexpr bool is_invocable_v = //see below
70 detail::is_invocable_impl<detail::traits<T>, Args...>::type::value;
73 // only available when variable templates are supported
74 template<typename Ret, typename T, typename... Args>
76 BOOST_CLBL_TRAITS_INLINE_VAR
78 constexpr bool is_invocable_r_v = //see below
80 detail::is_invocable_r_impl<
81 typename detail::is_invocable_impl<T, Args...>::type,
82 Ret, T, Args...>::type::value;
85 }} // namespace boost::callable_traits
93 * standalone c++11 implementation of c++17 `std::is_invocable`, `std::is_invocable_r`
94 [note ref-qualified overloads of `operator()` with different signatures are not handled correctly yet.]
96 [heading Example Program]
97 [import ../example/is_invocable.cpp]
103 #endif // #ifndef BOOST_CLBL_TRTS_IS_INVOCABLE_HPP