File indexing completed on 2025-01-18 09:28:52
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #ifndef BOOST_ASIO_EXPERIMENTAL_IMPL_USE_CORO_HPP
0013 #define BOOST_ASIO_EXPERIMENTAL_IMPL_USE_CORO_HPP
0014
0015 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
0016 # pragma once
0017 #endif
0018
0019 #include <boost/asio/deferred.hpp>
0020 #include <boost/asio/experimental/coro.hpp>
0021
0022 #include <boost/asio/detail/push_options.hpp>
0023
0024 namespace boost {
0025 namespace asio {
0026
0027 #if !defined(GENERATING_DOCUMENTATION)
0028
0029 template <typename Allocator, typename R>
0030 struct async_result<experimental::use_coro_t<Allocator>, R()>
0031 {
0032 template <typename Initiation, typename... InitArgs>
0033 static auto initiate_impl(Initiation initiation,
0034 std::allocator_arg_t, Allocator, InitArgs... args)
0035 -> experimental::coro<void() noexcept, void,
0036 boost::asio::associated_executor_t<Initiation>, Allocator>
0037 {
0038 co_await deferred_async_operation<R(), Initiation, InitArgs...>(
0039 deferred_init_tag{}, std::move(initiation), std::move(args)...);
0040 }
0041
0042 template <typename... InitArgs>
0043 static auto initiate_impl(boost::asio::detail::initiation_archetype<R()>,
0044 std::allocator_arg_t, Allocator, InitArgs... args)
0045 -> experimental::coro<void(), void,
0046 boost::asio::any_io_executor, Allocator>;
0047
0048 template <typename Initiation, typename... InitArgs>
0049 static auto initiate(Initiation initiation,
0050 experimental::use_coro_t<Allocator> tk, InitArgs&&... args)
0051 {
0052 return initiate_impl(std::move(initiation), std::allocator_arg,
0053 tk.get_allocator(), std::forward<InitArgs>(args)...);
0054 }
0055 };
0056
0057 template <typename Allocator, typename R>
0058 struct async_result<
0059 experimental::use_coro_t<Allocator>, R(boost::system::error_code)>
0060 {
0061 template <typename Initiation, typename... InitArgs>
0062 static auto initiate_impl(Initiation initiation,
0063 std::allocator_arg_t, Allocator, InitArgs... args)
0064 -> experimental::coro<void() noexcept, void,
0065 boost::asio::associated_executor_t<Initiation>, Allocator>
0066 {
0067 co_await deferred_async_operation<
0068 R(boost::system::error_code), Initiation, InitArgs...>(
0069 deferred_init_tag{}, std::move(initiation), std::move(args)...);
0070 }
0071
0072 template <typename... InitArgs>
0073 static auto initiate_impl(
0074 boost::asio::detail::initiation_archetype<R(boost::system::error_code)>,
0075 std::allocator_arg_t, Allocator, InitArgs... args)
0076 -> experimental::coro<void(), void,
0077 boost::asio::any_io_executor, Allocator>;
0078
0079 template <typename Initiation, typename... InitArgs>
0080 static auto initiate(Initiation initiation,
0081 experimental::use_coro_t<Allocator> tk, InitArgs&&... args)
0082 {
0083 return initiate_impl(std::move(initiation), std::allocator_arg,
0084 tk.get_allocator(), std::forward<InitArgs>(args)...);
0085 }
0086 };
0087
0088 template <typename Allocator, typename R>
0089 struct async_result<
0090 experimental::use_coro_t<Allocator>, R(std::exception_ptr)>
0091 {
0092 template <typename Initiation, typename... InitArgs>
0093 static auto initiate_impl(Initiation initiation,
0094 std::allocator_arg_t, Allocator, InitArgs... args)
0095 -> experimental::coro<void(), void,
0096 boost::asio::associated_executor_t<Initiation>, Allocator>
0097 {
0098 co_await deferred_async_operation<
0099 R(std::exception_ptr), Initiation, InitArgs...>(
0100 deferred_init_tag{}, std::move(initiation), std::move(args)...);
0101 }
0102
0103 template <typename... InitArgs>
0104 static auto initiate_impl(
0105 boost::asio::detail::initiation_archetype<R(std::exception_ptr)>,
0106 std::allocator_arg_t, Allocator, InitArgs... args)
0107 -> experimental::coro<void(), void,
0108 boost::asio::any_io_executor, Allocator>;
0109
0110 template <typename Initiation, typename... InitArgs>
0111 static auto initiate(Initiation initiation,
0112 experimental::use_coro_t<Allocator> tk, InitArgs&&... args)
0113 {
0114 return initiate_impl(std::move(initiation), std::allocator_arg,
0115 tk.get_allocator(), std::forward<InitArgs>(args)...);
0116 }
0117 };
0118
0119 template <typename Allocator, typename R, typename T>
0120 struct async_result<experimental::use_coro_t<Allocator>, R(T)>
0121 {
0122
0123 template <typename Initiation, typename... InitArgs>
0124 static auto initiate_impl(Initiation initiation,
0125 std::allocator_arg_t, Allocator, InitArgs... args)
0126 -> experimental::coro<void() noexcept, T,
0127 boost::asio::associated_executor_t<Initiation>, Allocator>
0128 {
0129 co_return co_await deferred_async_operation<R(T), Initiation, InitArgs...>(
0130 deferred_init_tag{}, std::move(initiation), std::move(args)...);
0131 }
0132
0133 template <typename... InitArgs>
0134 static auto initiate_impl(boost::asio::detail::initiation_archetype<R(T)>,
0135 std::allocator_arg_t, Allocator, InitArgs... args)
0136 -> experimental::coro<void() noexcept, T,
0137 boost::asio::any_io_executor, Allocator>;
0138
0139 template <typename Initiation, typename... InitArgs>
0140 static auto initiate(Initiation initiation,
0141 experimental::use_coro_t<Allocator> tk, InitArgs&&... args)
0142 {
0143 return initiate_impl(std::move(initiation), std::allocator_arg,
0144 tk.get_allocator(), std::forward<InitArgs>(args)...);
0145 }
0146 };
0147
0148 template <typename Allocator, typename R, typename T>
0149 struct async_result<
0150 experimental::use_coro_t<Allocator>, R(boost::system::error_code, T)>
0151 {
0152 template <typename Initiation, typename... InitArgs>
0153 static auto initiate_impl(Initiation initiation,
0154 std::allocator_arg_t, Allocator, InitArgs... args)
0155 -> experimental::coro<void(), T,
0156 boost::asio::associated_executor_t<Initiation>, Allocator>
0157 {
0158 co_return co_await deferred_async_operation<
0159 R(boost::system::error_code, T), Initiation, InitArgs...>(
0160 deferred_init_tag{}, std::move(initiation), std::move(args)...);
0161 }
0162
0163 template <typename... InitArgs>
0164 static auto initiate_impl(
0165 boost::asio::detail::initiation_archetype<
0166 R(boost::system::error_code, T)>,
0167 std::allocator_arg_t, Allocator, InitArgs... args)
0168 -> experimental::coro<void(), T, boost::asio::any_io_executor, Allocator>;
0169
0170 template <typename Initiation, typename... InitArgs>
0171 static auto initiate(Initiation initiation,
0172 experimental::use_coro_t<Allocator> tk, InitArgs&&... args)
0173 {
0174 return initiate_impl(std::move(initiation), std::allocator_arg,
0175 tk.get_allocator(), std::forward<InitArgs>(args)...);
0176 }
0177 };
0178
0179 template <typename Allocator, typename R, typename T>
0180 struct async_result<
0181 experimental::use_coro_t<Allocator>, R(std::exception_ptr, T)>
0182 {
0183 template <typename Initiation, typename... InitArgs>
0184 static auto initiate_impl(Initiation initiation,
0185 std::allocator_arg_t, Allocator, InitArgs... args)
0186 -> experimental::coro<void(), T,
0187 boost::asio::associated_executor_t<Initiation>, Allocator>
0188 {
0189 co_return co_await deferred_async_operation<
0190 R(std::exception_ptr, T), Initiation, InitArgs...>(
0191 deferred_init_tag{}, std::move(initiation), std::move(args)...);
0192 }
0193
0194 template <typename... InitArgs>
0195 static auto initiate_impl(
0196 boost::asio::detail::initiation_archetype<R(std::exception_ptr, T)>,
0197 std::allocator_arg_t, Allocator, InitArgs... args)
0198 -> experimental::coro<void(), T, boost::asio::any_io_executor, Allocator>;
0199
0200 template <typename Initiation, typename... InitArgs>
0201 static auto initiate(Initiation initiation,
0202 experimental::use_coro_t<Allocator> tk, InitArgs&&... args)
0203 {
0204 return initiate_impl(std::move(initiation), std::allocator_arg,
0205 tk.get_allocator(), std::forward<InitArgs>(args)...);
0206 }
0207 };
0208
0209 #endif
0210
0211 }
0212 }
0213
0214 #include <boost/asio/detail/pop_options.hpp>
0215
0216 #endif