// // execution/receiver.hpp // ~~~~~~~~~~~~~~~~~~~~~~ // // Copyright (c) 2003-2021 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // #ifndef BOOST_ASIO_EXECUTION_RECEIVER_HPP #define BOOST_ASIO_EXECUTION_RECEIVER_HPP #if defined(_MSC_VER) && (_MSC_VER >= 1200) # pragma once #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) #include #include #include #include #include #include #if defined(BOOST_ASIO_HAS_STD_EXCEPTION_PTR) # include #else // defined(BOOST_ASIO_HAS_STD_EXCEPTION_PTR) # include #endif // defined(BOOST_ASIO_HAS_STD_EXCEPTION_PTR) #if defined(BOOST_ASIO_HAS_DEDUCED_SET_DONE_FREE_TRAIT) \ && defined(BOOST_ASIO_HAS_DEDUCED_SET_DONE_MEMBER_TRAIT) \ && defined(BOOST_ASIO_HAS_DEDUCED_SET_ERROR_FREE_TRAIT) \ && defined(BOOST_ASIO_HAS_DEDUCED_SET_ERROR_MEMBER_TRAIT) \ && defined(BOOST_ASIO_HAS_DEDUCED_SET_VALUE_FREE_TRAIT) \ && defined(BOOST_ASIO_HAS_DEDUCED_SET_VALUE_MEMBER_TRAIT) \ && defined(BOOST_ASIO_HAS_DEDUCED_RECEIVER_OF_FREE_TRAIT) \ && defined(BOOST_ASIO_HAS_DEDUCED_RECEIVER_OF_MEMBER_TRAIT) # define BOOST_ASIO_HAS_DEDUCED_EXECUTION_IS_RECEIVER_TRAIT 1 #endif // defined(BOOST_ASIO_HAS_DEDUCED_SET_DONE_FREE_TRAIT) // && defined(BOOST_ASIO_HAS_DEDUCED_SET_DONE_MEMBER_TRAIT) // && defined(BOOST_ASIO_HAS_DEDUCED_SET_ERROR_FREE_TRAIT) // && defined(BOOST_ASIO_HAS_DEDUCED_SET_ERROR_MEMBER_TRAIT) // && defined(BOOST_ASIO_HAS_DEDUCED_SET_VALUE_FREE_TRAIT) // && defined(BOOST_ASIO_HAS_DEDUCED_SET_VALUE_MEMBER_TRAIT) // && defined(BOOST_ASIO_HAS_DEDUCED_RECEIVER_OF_FREE_TRAIT) // && defined(BOOST_ASIO_HAS_DEDUCED_RECEIVER_OF_MEMBER_TRAIT) #include namespace boost { namespace asio { namespace execution { namespace detail { template struct is_receiver_base : integral_constant::type>::value && is_constructible::type, T>::value > { }; } // namespace detail #if defined(BOOST_ASIO_HAS_STD_EXCEPTION_PTR) # define BOOST_ASIO_EXECUTION_RECEIVER_ERROR_DEFAULT = std::exception_ptr #else // defined(BOOST_ASIO_HAS_STD_EXCEPTION_PTR) # define BOOST_ASIO_EXECUTION_RECEIVER_ERROR_DEFAULT \ = ::boost::system::error_code #endif // defined(BOOST_ASIO_HAS_STD_EXCEPTION_PTR) /// The is_receiver trait detects whether a type T satisfies the /// execution::receiver concept. /** * Class template @c is_receiver is a type trait that is derived from @c * true_type if the type @c T meets the concept definition for a receiver for * error type @c E, otherwise @c false_type. */ template struct is_receiver : #if defined(GENERATING_DOCUMENTATION) integral_constant #else // defined(GENERATING_DOCUMENTATION) conditional< can_set_done::type>::value && is_nothrow_set_done::type>::value && can_set_error::type, E>::value && is_nothrow_set_error::type, E>::value, detail::is_receiver_base, false_type >::type #endif // defined(GENERATING_DOCUMENTATION) { }; #if defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES) template BOOST_ASIO_CONSTEXPR const bool is_receiver_v = is_receiver::value; #endif // defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES) #if defined(BOOST_ASIO_HAS_CONCEPTS) template BOOST_ASIO_CONCEPT receiver = is_receiver::value; #define BOOST_ASIO_EXECUTION_RECEIVER ::boost::asio::execution::receiver #else // defined(BOOST_ASIO_HAS_CONCEPTS) #define BOOST_ASIO_EXECUTION_RECEIVER typename #endif // defined(BOOST_ASIO_HAS_CONCEPTS) #if defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES) \ || defined(GENERATING_DOCUMENTATION) /// The is_receiver_of trait detects whether a type T satisfies the /// execution::receiver_of concept for some set of value arguments. /** * Class template @c is_receiver_of is a type trait that is derived from @c * true_type if the type @c T meets the concept definition for a receiver for * value arguments @c Vs, otherwise @c false_type. */ template struct is_receiver_of : #if defined(GENERATING_DOCUMENTATION) integral_constant #else // defined(GENERATING_DOCUMENTATION) conditional< is_receiver::value, can_set_value::type, Vs...>, false_type >::type #endif // defined(GENERATING_DOCUMENTATION) { }; #if defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES) template BOOST_ASIO_CONSTEXPR const bool is_receiver_of_v = is_receiver_of::value; #endif // defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES) #if defined(BOOST_ASIO_HAS_CONCEPTS) template BOOST_ASIO_CONCEPT receiver_of = is_receiver_of::value; #define BOOST_ASIO_EXECUTION_RECEIVER_OF_0 \ ::boost::asio::execution::receiver_of #define BOOST_ASIO_EXECUTION_RECEIVER_OF_1(v) \ ::boost::asio::execution::receiver_of #else // defined(BOOST_ASIO_HAS_CONCEPTS) #define BOOST_ASIO_EXECUTION_RECEIVER_OF_0 typename #define BOOST_ASIO_EXECUTION_RECEIVER_OF_1(v) typename #endif // defined(BOOST_ASIO_HAS_CONCEPTS) #else // defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES) // || defined(GENERATING_DOCUMENTATION) template struct is_receiver_of; template struct is_receiver_of : conditional< is_receiver::value, can_set_value::type>, false_type >::type { }; #define BOOST_ASIO_PRIVATE_RECEIVER_OF_TRAITS_DEF(n) \ template \ struct is_receiver_of : \ conditional< \ conditional, void>::type::value, \ can_set_value< \ typename remove_cvref::type, \ BOOST_ASIO_VARIADIC_TARGS(n)>, \ false_type \ >::type \ { \ }; \ /**/ BOOST_ASIO_VARIADIC_GENERATE(BOOST_ASIO_PRIVATE_RECEIVER_OF_TRAITS_DEF) #undef BOOST_ASIO_PRIVATE_RECEIVER_OF_TRAITS_DEF #define BOOST_ASIO_EXECUTION_RECEIVER_OF_0 typename #define BOOST_ASIO_EXECUTION_RECEIVER_OF_1(v) typename #endif // defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES) // || defined(GENERATING_DOCUMENTATION) #if defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES) \ || defined(GENERATING_DOCUMENTATION) /// The is_nothrow_receiver_of trait detects whether a type T satisfies the /// execution::receiver_of concept for some set of value arguments, with a /// noexcept @c set_value operation. /** * Class template @c is_nothrow_receiver_of is a type trait that is derived * from @c true_type if the type @c T meets the concept definition for a * receiver for value arguments @c Vs, and the expression * execution::set_value(declval(), declval()...) is noexcept, * otherwise @c false_type. */ template struct is_nothrow_receiver_of : #if defined(GENERATING_DOCUMENTATION) integral_constant #else // defined(GENERATING_DOCUMENTATION) integral_constant::value && is_nothrow_set_value::type, Vs...>::value > #endif // defined(GENERATING_DOCUMENTATION) { }; #if defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES) template BOOST_ASIO_CONSTEXPR const bool is_nothrow_receiver_of_v = is_nothrow_receiver_of::value; #endif // defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES) #else // defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES) // || defined(GENERATING_DOCUMENTATION) template struct is_nothrow_receiver_of; template struct is_nothrow_receiver_of : integral_constant::value && is_nothrow_set_value::type>::value > { }; #define BOOST_ASIO_PRIVATE_NOTHROW_RECEIVER_OF_TRAITS_DEF(n) \ template \ struct is_nothrow_receiver_of : \ integral_constant::value \ && is_nothrow_set_value::type, \ BOOST_ASIO_VARIADIC_TARGS(n)>::value \ > \ { \ }; \ /**/ BOOST_ASIO_VARIADIC_GENERATE(BOOST_ASIO_PRIVATE_NOTHROW_RECEIVER_OF_TRAITS_DEF) #undef BOOST_ASIO_PRIVATE_NOTHROW_RECEIVER_OF_TRAITS_DEF #endif // defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES) // || defined(GENERATING_DOCUMENTATION) } // namespace execution } // namespace asio } // namespace boost #include #endif // BOOST_ASIO_EXECUTION_RECEIVER_HPP