]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/boost/beast/core/detail/is_invocable.hpp
import quincy beta 17.1.0
[ceph.git] / ceph / src / boost / boost / beast / core / detail / is_invocable.hpp
CommitLineData
92f5a8d4
TL
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
20effc67
TL
13#include <boost/asio/async_result.hpp>
14#include <boost/type_traits/make_void.hpp>
92f5a8d4
TL
15#include <type_traits>
16#include <utility>
17
18namespace boost {
19namespace beast {
20namespace detail {
21
22template<class R, class C, class ...A>
23auto
24is_invocable_test(C&& c, int, A&& ...a)
25 -> decltype(std::is_convertible<
26 decltype(c(std::forward<A>(a)...)), R>::value ||
27 std::is_same<R, void>::value,
28 std::true_type());
29
30template<class R, class C, class ...A>
31std::false_type
32is_invocable_test(C&& c, long, A&& ...a);
33
34/** Metafunction returns `true` if F callable as R(A...)
35
36 Example:
37
38 @code
39 is_invocable<T, void(std::string)>::value
40 @endcode
41*/
42/** @{ */
43template<class C, class F>
44struct is_invocable : std::false_type
45{
46};
47
48template<class C, class R, class ...A>
49struct is_invocable<C, R(A...)>
50 : decltype(is_invocable_test<R>(
51 std::declval<C>(), 1, std::declval<A>()...))
52{
53};
54/** @} */
55
20effc67
TL
56template<class CompletionToken, class Signature, class = void>
57struct is_completion_token_for : std::false_type
58{
59};
60
61struct any_initiation
62{
63 template<class...AnyArgs>
64 void operator()(AnyArgs&&...);
65};
66
67template<class CompletionToken, class R, class...Args>
68struct is_completion_token_for<
69 CompletionToken, R(Args...), boost::void_t<decltype(
70 boost::asio::async_initiate<CompletionToken, R(Args...)>(
71 any_initiation(), std::declval<CompletionToken&>())
72 )>> : std::true_type
73{
74};
75
92f5a8d4
TL
76} // detail
77} // beast
78} // boost
79
80#endif