File indexing completed on 2025-06-30 08:08:09
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_ASIO_IMPL_CONSIGN_HPP
0012 #define BOOST_ASIO_IMPL_CONSIGN_HPP
0013
0014 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
0015 # pragma once
0016 #endif
0017
0018 #include <boost/asio/detail/config.hpp>
0019 #include <boost/asio/associator.hpp>
0020 #include <boost/asio/async_result.hpp>
0021 #include <boost/asio/detail/handler_cont_helpers.hpp>
0022 #include <boost/asio/detail/initiation_base.hpp>
0023 #include <boost/asio/detail/type_traits.hpp>
0024 #include <boost/asio/detail/utility.hpp>
0025
0026 #include <boost/asio/detail/push_options.hpp>
0027
0028 namespace boost {
0029 namespace asio {
0030 namespace detail {
0031
0032
0033 template <typename Handler, typename... Values>
0034 class consign_handler
0035 {
0036 public:
0037 typedef void result_type;
0038
0039 template <typename H>
0040 consign_handler(H&& handler, std::tuple<Values...> values)
0041 : handler_(static_cast<H&&>(handler)),
0042 values_(static_cast<std::tuple<Values...>&&>(values))
0043 {
0044 }
0045
0046 template <typename... Args>
0047 void operator()(Args&&... args)
0048 {
0049 static_cast<Handler&&>(handler_)(static_cast<Args&&>(args)...);
0050 }
0051
0052
0053 Handler handler_;
0054 std::tuple<Values...> values_;
0055 };
0056
0057 template <typename Handler>
0058 inline bool asio_handler_is_continuation(
0059 consign_handler<Handler>* this_handler)
0060 {
0061 return boost_asio_handler_cont_helpers::is_continuation(
0062 this_handler->handler_);
0063 }
0064
0065 }
0066
0067 #if !defined(GENERATING_DOCUMENTATION)
0068
0069 template <typename CompletionToken, typename... Values, typename... Signatures>
0070 struct async_result<consign_t<CompletionToken, Values...>, Signatures...>
0071 : async_result<CompletionToken, Signatures...>
0072 {
0073 template <typename Initiation>
0074 struct init_wrapper : detail::initiation_base<Initiation>
0075 {
0076 using detail::initiation_base<Initiation>::initiation_base;
0077
0078 template <typename Handler, typename... Args>
0079 void operator()(Handler&& handler,
0080 std::tuple<Values...> values, Args&&... args) &&
0081 {
0082 static_cast<Initiation&&>(*this)(
0083 detail::consign_handler<decay_t<Handler>, Values...>(
0084 static_cast<Handler&&>(handler),
0085 static_cast<std::tuple<Values...>&&>(values)),
0086 static_cast<Args&&>(args)...);
0087 }
0088
0089 template <typename Handler, typename... Args>
0090 void operator()(Handler&& handler,
0091 std::tuple<Values...> values, Args&&... args) const &
0092 {
0093 static_cast<const Initiation&>(*this)(
0094 detail::consign_handler<decay_t<Handler>, Values...>(
0095 static_cast<Handler&&>(handler),
0096 static_cast<std::tuple<Values...>&&>(values)),
0097 static_cast<Args&&>(args)...);
0098 }
0099 };
0100
0101 template <typename Initiation, typename RawCompletionToken, typename... Args>
0102 static auto initiate(Initiation&& initiation,
0103 RawCompletionToken&& token, Args&&... args)
0104 -> decltype(
0105 async_initiate<CompletionToken, Signatures...>(
0106 init_wrapper<decay_t<Initiation>>(
0107 static_cast<Initiation&&>(initiation)),
0108 token.token_, static_cast<std::tuple<Values...>&&>(token.values_),
0109 static_cast<Args&&>(args)...))
0110 {
0111 return async_initiate<CompletionToken, Signatures...>(
0112 init_wrapper<decay_t<Initiation>>(
0113 static_cast<Initiation&&>(initiation)),
0114 token.token_, static_cast<std::tuple<Values...>&&>(token.values_),
0115 static_cast<Args&&>(args)...);
0116 }
0117 };
0118
0119 template <template <typename, typename> class Associator,
0120 typename Handler, typename... Values, typename DefaultCandidate>
0121 struct associator<Associator,
0122 detail::consign_handler<Handler, Values...>, DefaultCandidate>
0123 : Associator<Handler, DefaultCandidate>
0124 {
0125 static typename Associator<Handler, DefaultCandidate>::type get(
0126 const detail::consign_handler<Handler, Values...>& h) noexcept
0127 {
0128 return Associator<Handler, DefaultCandidate>::get(h.handler_);
0129 }
0130
0131 static auto get(const detail::consign_handler<Handler, Values...>& h,
0132 const DefaultCandidate& c) noexcept
0133 -> decltype(Associator<Handler, DefaultCandidate>::get(h.handler_, c))
0134 {
0135 return Associator<Handler, DefaultCandidate>::get(h.handler_, c);
0136 }
0137 };
0138
0139 #endif
0140
0141 }
0142 }
0143
0144 #include <boost/asio/detail/pop_options.hpp>
0145
0146 #endif