// // experimental/detail/channel_message.hpp // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // Copyright (c) 2003-2023 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 ASIO_EXPERIMENTAL_DETAIL_CHANNEL_MESSAGE_HPP #define ASIO_EXPERIMENTAL_DETAIL_CHANNEL_MESSAGE_HPP #if defined(_MSC_VER) && (_MSC_VER >= 1200) # pragma once #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) #include "asio/detail/config.hpp" #include #include "asio/detail/type_traits.hpp" #include "asio/detail/utility.hpp" #include "asio/detail/push_options.hpp" namespace asio { namespace experimental { namespace detail { template class channel_message; template class channel_message { public: channel_message(int) { } template void receive(Handler& handler) { static_cast(handler)(); } }; template class channel_message { public: template channel_message(int, T0&& t0) : arg0_(static_cast(t0)) { } template void receive(Handler& handler) { static_cast(handler)( static_cast(arg0_)); } private: typedef decay_t arg0_type; arg0_type arg0_; }; template class channel_message { public: template channel_message(int, T0&& t0, T1&& t1) : arg0_(static_cast(t0)), arg1_(static_cast(t1)) { } template void receive(Handler& handler) { static_cast(handler)( static_cast(arg0_), static_cast(arg1_)); } private: typedef decay_t arg0_type; arg0_type arg0_; typedef decay_t arg1_type; arg1_type arg1_; }; template class channel_message { public: template channel_message(int, T&&... t) : args_(static_cast(t)...) { } template void receive(Handler& h) { this->do_receive(h, asio::detail::index_sequence_for()); } private: template void do_receive(Handler& h, asio::detail::index_sequence) { static_cast(h)( std::get(static_cast(args_))...); } typedef std::tuple...> args_type; args_type args_; }; } // namespace detail } // namespace experimental } // namespace asio #include "asio/detail/pop_options.hpp" #endif // ASIO_EXPERIMENTAL_DETAIL_CHANNEL_MESSAGE_HPP