// // impl/consign.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 ASIO_IMPL_CONSIGN_HPP #define ASIO_IMPL_CONSIGN_HPP #if defined(_MSC_VER) && (_MSC_VER >= 1200) # pragma once #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) #include "asio/detail/config.hpp" #include "asio/associator.hpp" #include "asio/async_result.hpp" #include "asio/detail/handler_cont_helpers.hpp" #include "asio/detail/type_traits.hpp" #include "asio/detail/utility.hpp" #include "asio/detail/push_options.hpp" namespace asio { namespace detail { // Class to adapt a consign_t as a completion handler. template class consign_handler { public: typedef void result_type; template consign_handler(H&& handler, std::tuple values) : handler_(static_cast(handler)), values_(static_cast&&>(values)) { } template void operator()(Args&&... args) { static_cast(handler_)(static_cast(args)...); } //private: Handler handler_; std::tuple values_; }; template inline bool asio_handler_is_continuation( consign_handler* this_handler) { return asio_handler_cont_helpers::is_continuation( this_handler->handler_); } } // namespace detail #if !defined(GENERATING_DOCUMENTATION) template struct async_result, Signatures...> : async_result { template struct init_wrapper { init_wrapper(Initiation init) : initiation_(static_cast(init)) { } template void operator()(Handler&& handler, std::tuple values, Args&&... args) { static_cast(initiation_)( detail::consign_handler, Values...>( static_cast(handler), static_cast&&>(values)), static_cast(args)...); } Initiation initiation_; }; template static auto initiate(Initiation&& initiation, RawCompletionToken&& token, Args&&... args) -> decltype( async_initiate( init_wrapper>( static_cast(initiation)), token.token_, static_cast&&>(token.values_), static_cast(args)...)) { return async_initiate( init_wrapper>( static_cast(initiation)), token.token_, static_cast&&>(token.values_), static_cast(args)...); } }; template