From 966a24cbbe00eb8c06e480855d3ae5ccd18c7d7e Mon Sep 17 00:00:00 2001 From: Christopher Kohlhoff Date: Tue, 25 Jun 2024 22:39:51 +1000 Subject: [PATCH] Change redirect_error to propagate an initiation object's executor. --- asio/include/asio/impl/redirect_error.hpp | 37 +++++++++++++---------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/asio/include/asio/impl/redirect_error.hpp b/asio/include/asio/impl/redirect_error.hpp index a82e6afe14..29d55cbe52 100644 --- a/asio/include/asio/impl/redirect_error.hpp +++ b/asio/include/asio/impl/redirect_error.hpp @@ -20,6 +20,7 @@ #include "asio/associator.hpp" #include "asio/async_result.hpp" #include "asio/detail/handler_cont_helpers.hpp" +#include "asio/detail/initiation_base.hpp" #include "asio/detail/type_traits.hpp" #include "asio/system_error.hpp" @@ -183,25 +184,30 @@ struct async_result, Signature> : async_result::type> { - - struct init_wrapper + template + struct init_wrapper : detail::initiation_base { - explicit init_wrapper(asio::error_code& ec) - : ec_(ec) + using detail::initiation_base::initiation_base; + + template + void operator()(Handler&& handler, + asio::error_code* ec, Args&&... args) && { + static_cast(*this)( + detail::redirect_error_handler>( + *ec, static_cast(handler)), + static_cast(args)...); } - template + template void operator()(Handler&& handler, - Initiation&& initiation, Args&&... args) const + asio::error_code* ec, Args&&... args) const & { - static_cast(initiation)( + static_cast(*this)( detail::redirect_error_handler>( - ec_, static_cast(handler)), + *ec, static_cast(handler)), static_cast(args)...); } - - asio::error_code& ec_; }; template @@ -213,18 +219,17 @@ struct async_result, Signature> is_const>::value, const CompletionToken, CompletionToken>, typename detail::redirect_error_signature::type>( - declval(), token.token_, - static_cast(initiation), - static_cast(args)...)) + declval>>(), + token.token_, &token.ec_, static_cast(args)...)) { return async_initiate< conditional_t< is_const>::value, const CompletionToken, CompletionToken>, typename detail::redirect_error_signature::type>( - init_wrapper(token.ec_), token.token_, - static_cast(initiation), - static_cast(args)...); + init_wrapper>( + static_cast(initiation)), + token.token_, &token.ec_, static_cast(args)...); } };