// // experimental/detail/channel_message.hpp // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // Copyright (c) 2003-2022 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_MESSAGE_HPP #define BOOST_ASIO_EXPERIMENTAL_DETAIL_CHANNEL_MESSAGE_HPP #if defined(_MSC_VER) && (_MSC_VER >= 1200) # pragma once #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) #include #include #include #include namespace boost { namespace asio { namespace experimental { namespace detail { template class channel_message; template class channel_message { public: channel_message(int) { } template void receive(Handler& handler) { BOOST_ASIO_MOVE_OR_LVALUE(Handler)(handler)(); } }; template class channel_message { public: template channel_message(int, BOOST_ASIO_MOVE_ARG(T0) t0) : arg0_(BOOST_ASIO_MOVE_CAST(T0)(t0)) { } template void receive(Handler& handler) { BOOST_ASIO_MOVE_OR_LVALUE(Handler)(handler)( BOOST_ASIO_MOVE_CAST(arg0_type)(arg0_)); } private: typedef typename decay::type arg0_type; arg0_type arg0_; }; template class channel_message { public: template channel_message(int, BOOST_ASIO_MOVE_ARG(T0) t0, BOOST_ASIO_MOVE_ARG(T1) t1) : arg0_(BOOST_ASIO_MOVE_CAST(T0)(t0)), arg1_(BOOST_ASIO_MOVE_CAST(T1)(t1)) { } template void receive(Handler& handler) { BOOST_ASIO_MOVE_OR_LVALUE(Handler)(handler)( BOOST_ASIO_MOVE_CAST(arg0_type)(arg0_), BOOST_ASIO_MOVE_CAST(arg1_type)(arg1_)); } private: typedef typename decay::type arg0_type; arg0_type arg0_; typedef typename decay::type arg1_type; arg1_type arg1_; }; template class channel_message { public: template channel_message(int, BOOST_ASIO_MOVE_ARG(T)... t) : args_(BOOST_ASIO_MOVE_CAST(T)(t)...) { } template void receive(Handler& h) { std::apply(BOOST_ASIO_MOVE_OR_LVALUE(Handler)(h), BOOST_ASIO_MOVE_CAST(args_type)(args_)); } private: typedef std::tuple::type...> args_type; args_type args_; }; } // namespace detail } // namespace experimental } // namespace asio } // namespace boost #include #endif // BOOST_ASIO_EXPERIMENTAL_DETAIL_CHANNEL_MESSAGE_HPP