// // experimental/detail/channel_send_functions.hpp // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // Copyright (c) 2003-2024 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_EXPERIMENTAL_DETAIL_CHANNEL_SEND_FUNCTIONS_HPP #define BOOST_ASIO_EXPERIMENTAL_DETAIL_CHANNEL_SEND_FUNCTIONS_HPP #if defined(_MSC_VER) && (_MSC_VER >= 1200) # pragma once #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) #include #include #include #include #include #include namespace boost { namespace asio { namespace experimental { namespace detail { template class channel_send_functions; template class channel_send_functions { public: template enable_if_t< is_constructible, int, Args2...>::value, bool > try_send(Args2&&... args) { typedef boost::asio::detail::completion_message message_type; Derived* self = static_cast(this); return self->service_->template try_send( self->impl_, false, static_cast(args)...); } template enable_if_t< is_constructible, int, Args2...>::value, bool > try_send_via_dispatch(Args2&&... args) { typedef boost::asio::detail::completion_message message_type; Derived* self = static_cast(this); return self->service_->template try_send( self->impl_, true, static_cast(args)...); } template enable_if_t< is_constructible, int, Args2...>::value, std::size_t > try_send_n(std::size_t count, Args2&&... args) { typedef boost::asio::detail::completion_message message_type; Derived* self = static_cast(this); return self->service_->template try_send_n( self->impl_, count, false, static_cast(args)...); } template enable_if_t< is_constructible, int, Args2...>::value, std::size_t > try_send_n_via_dispatch(std::size_t count, Args2&&... args) { typedef boost::asio::detail::completion_message message_type; Derived* self = static_cast(this); return self->service_->template try_send_n( self->impl_, count, true, static_cast(args)...); } template < BOOST_ASIO_COMPLETION_TOKEN_FOR(void (boost::system::error_code)) CompletionToken BOOST_ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(Executor)> auto async_send(Args... args, CompletionToken&& token BOOST_ASIO_DEFAULT_COMPLETION_TOKEN(Executor)) -> decltype( async_initiate( declval::initiate_async_send>(), token, declval::payload_type>())) { typedef typename Derived::payload_type payload_type; typedef boost::asio::detail::completion_message message_type; Derived* self = static_cast(this); return async_initiate( typename Derived::initiate_async_send(self), token, payload_type(message_type(0, static_cast(args)...))); } }; template class channel_send_functions : public channel_send_functions { public: using channel_send_functions::try_send; using channel_send_functions::async_send; template enable_if_t< is_constructible, int, Args2...>::value, bool > try_send(Args2&&... args) { typedef boost::asio::detail::completion_message message_type; Derived* self = static_cast(this); return self->service_->template try_send( self->impl_, false, static_cast(args)...); } template enable_if_t< is_constructible, int, Args2...>::value, bool > try_send_via_dispatch(Args2&&... args) { typedef boost::asio::detail::completion_message message_type; Derived* self = static_cast(this); return self->service_->template try_send( self->impl_, true, static_cast(args)...); } template enable_if_t< is_constructible, int, Args2...>::value, std::size_t > try_send_n(std::size_t count, Args2&&... args) { typedef boost::asio::detail::completion_message message_type; Derived* self = static_cast(this); return self->service_->template try_send_n( self->impl_, count, false, static_cast(args)...); } template enable_if_t< is_constructible, int, Args2...>::value, std::size_t > try_send_n_via_dispatch(std::size_t count, Args2&&... args) { typedef boost::asio::detail::completion_message message_type; Derived* self = static_cast(this); return self->service_->template try_send_n( self->impl_, count, true, static_cast(args)...); } template < BOOST_ASIO_COMPLETION_TOKEN_FOR(void (boost::system::error_code)) CompletionToken BOOST_ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(Executor)> auto async_send(Args... args, CompletionToken&& token BOOST_ASIO_DEFAULT_COMPLETION_TOKEN(Executor)) -> decltype( async_initiate( declval::initiate_async_send>(), token, declval::payload_type>())) { typedef typename Derived::payload_type payload_type; typedef boost::asio::detail::completion_message message_type; Derived* self = static_cast(this); return async_initiate( typename Derived::initiate_async_send(self), token, payload_type(message_type(0, static_cast(args)...))); } }; } // namespace detail } // namespace experimental } // namespace asio } // namespace boost #include #endif // BOOST_ASIO_EXPERIMENTAL_DETAIL_CHANNEL_SEND_FUNCTIONS_HPP