Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:29:24

0001 //
0002 // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
0003 //
0004 // Distributed under the Boost Software License, Version 1.0. (See accompanying
0005 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0006 //
0007 // Official repository: https://github.com/boostorg/beast
0008 //
0009 
0010 #ifndef BOOST_BEAST_DETAIL_IS_INVOCABLE_HPP
0011 #define BOOST_BEAST_DETAIL_IS_INVOCABLE_HPP
0012 
0013 #include <boost/asio/async_result.hpp>
0014 #include <boost/type_traits/make_void.hpp>
0015 #include <type_traits>
0016 #include <utility>
0017 
0018 namespace boost {
0019 namespace beast {
0020 namespace detail {
0021 
0022 template<class R, class C, class ...A>
0023 auto
0024 is_invocable_test(C&& c, int, A&& ...a)
0025     -> decltype(std::is_convertible<
0026         decltype(c(std::forward<A>(a)...)), R>::value ||
0027             std::is_same<R, void>::value,
0028                 std::true_type());
0029 
0030 template<class R, class C, class ...A>
0031 std::false_type
0032 is_invocable_test(C&& c, long, A&& ...a);
0033 
0034 /** Metafunction returns `true` if F callable as R(A...)
0035 
0036     Example:
0037 
0038     @code
0039     is_invocable<T, void(std::string)>::value
0040     @endcode
0041 */
0042 /** @{ */
0043 template<class C, class F>
0044 struct is_invocable : std::false_type
0045 {
0046 };
0047 
0048 template<class C, class R, class ...A>
0049 struct is_invocable<C, R(A...)>
0050     : decltype(is_invocable_test<R>(
0051         std::declval<C>(), 1, std::declval<A>()...))
0052 {
0053 };
0054 /** @} */
0055 
0056 template<class CompletionToken, class Signature, class = void>
0057 struct is_completion_token_for : std::false_type
0058 {
0059 };
0060 
0061 struct any_initiation
0062 {
0063     template<class...AnyArgs>
0064     void operator()(AnyArgs&&...);
0065 };
0066 
0067 template<class CompletionToken, class R, class...Args>
0068 struct is_completion_token_for<
0069     CompletionToken, R(Args...), boost::void_t<decltype(
0070         boost::asio::async_initiate<CompletionToken, R(Args...)>(
0071             any_initiation(), std::declval<CompletionToken&>())
0072         )>> : std::true_type
0073 {
0074 };
0075 
0076 } // detail
0077 } // beast
0078 } // boost
0079 
0080 #endif