]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/beast/core/detail/is_invocable.hpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / boost / beast / core / detail / is_invocable.hpp
1 //
2 // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
3 //
4 // Distributed under the Boost Software License, Version 1.0. (See accompanying
5 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 //
7 // Official repository: https://github.com/boostorg/beast
8 //
9
10 #ifndef BOOST_BEAST_DETAIL_IS_INVOCABLE_HPP
11 #define BOOST_BEAST_DETAIL_IS_INVOCABLE_HPP
12
13 #include <type_traits>
14 #include <utility>
15
16 namespace boost {
17 namespace beast {
18 namespace detail {
19
20 template<class R, class C, class ...A>
21 auto
22 is_invocable_test(C&& c, int, A&& ...a)
23 -> decltype(std::is_convertible<
24 decltype(c(std::forward<A>(a)...)), R>::value ||
25 std::is_same<R, void>::value,
26 std::true_type());
27
28 template<class R, class C, class ...A>
29 std::false_type
30 is_invocable_test(C&& c, long, A&& ...a);
31
32 /** Metafunction returns `true` if F callable as R(A...)
33
34 Example:
35
36 @code
37 is_invocable<T, void(std::string)>::value
38 @endcode
39 */
40 /** @{ */
41 template<class C, class F>
42 struct is_invocable : std::false_type
43 {
44 };
45
46 template<class C, class R, class ...A>
47 struct is_invocable<C, R(A...)>
48 : decltype(is_invocable_test<R>(
49 std::declval<C>(), 1, std::declval<A>()...))
50 {
51 };
52 /** @} */
53
54 } // detail
55 } // beast
56 } // boost
57
58 #endif