|
2 | 2 | // async_result.hpp
|
3 | 3 | // ~~~~~~~~~~~~~~~~
|
4 | 4 | //
|
5 |
| -// Copyright (c) 2003-2023 Christopher M. Kohlhoff (chris at kohlhoff dot com) |
| 5 | +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) |
6 | 6 | //
|
7 | 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
|
8 | 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
@@ -97,39 +97,39 @@ struct is_completion_handler_for : false_type
|
97 | 97 |
|
98 | 98 | template <typename T, typename R, typename... Args>
|
99 | 99 | struct is_completion_handler_for<T, R(Args...)>
|
100 |
| - : integral_constant<bool, (callable_with<T, Args...>)> |
| 100 | + : integral_constant<bool, (callable_with<decay_t<T>, Args...>)> |
101 | 101 | {
|
102 | 102 | };
|
103 | 103 |
|
104 | 104 | template <typename T, typename R, typename... Args>
|
105 | 105 | struct is_completion_handler_for<T, R(Args...) &>
|
106 |
| - : integral_constant<bool, (callable_with<T&, Args...>)> |
| 106 | + : integral_constant<bool, (callable_with<decay_t<T>&, Args...>)> |
107 | 107 | {
|
108 | 108 | };
|
109 | 109 |
|
110 | 110 | template <typename T, typename R, typename... Args>
|
111 | 111 | struct is_completion_handler_for<T, R(Args...) &&>
|
112 |
| - : integral_constant<bool, (callable_with<T&&, Args...>)> |
| 112 | + : integral_constant<bool, (callable_with<decay_t<T>&&, Args...>)> |
113 | 113 | {
|
114 | 114 | };
|
115 | 115 |
|
116 | 116 | # if defined(ASIO_HAS_NOEXCEPT_FUNCTION_TYPE)
|
117 | 117 |
|
118 | 118 | template <typename T, typename R, typename... Args>
|
119 | 119 | struct is_completion_handler_for<T, R(Args...) noexcept>
|
120 |
| - : integral_constant<bool, (callable_with<T, Args...>)> |
| 120 | + : integral_constant<bool, (callable_with<decay_t<T>, Args...>)> |
121 | 121 | {
|
122 | 122 | };
|
123 | 123 |
|
124 | 124 | template <typename T, typename R, typename... Args>
|
125 | 125 | struct is_completion_handler_for<T, R(Args...) & noexcept>
|
126 |
| - : integral_constant<bool, (callable_with<T&, Args...>)> |
| 126 | + : integral_constant<bool, (callable_with<decay_t<T>&, Args...>)> |
127 | 127 | {
|
128 | 128 | };
|
129 | 129 |
|
130 | 130 | template <typename T, typename R, typename... Args>
|
131 | 131 | struct is_completion_handler_for<T, R(Args...) && noexcept>
|
132 |
| - : integral_constant<bool, (callable_with<T&&, Args...>)> |
| 132 | + : integral_constant<bool, (callable_with<decay_t<T>&&, Args...>)> |
133 | 133 | {
|
134 | 134 | };
|
135 | 135 |
|
@@ -176,37 +176,84 @@ ASIO_CONCEPT completion_handler_for =
|
176 | 176 | namespace detail {
|
177 | 177 |
|
178 | 178 | template <typename T>
|
179 |
| -struct is_simple_completion_signature : false_type |
| 179 | +struct is_lvalue_completion_signature : false_type |
| 180 | +{ |
| 181 | +}; |
| 182 | + |
| 183 | +template <typename R, typename... Args> |
| 184 | +struct is_lvalue_completion_signature<R(Args...) &> : true_type |
| 185 | +{ |
| 186 | +}; |
| 187 | + |
| 188 | +# if defined(ASIO_HAS_NOEXCEPT_FUNCTION_TYPE) |
| 189 | + |
| 190 | +template <typename R, typename... Args> |
| 191 | +struct is_lvalue_completion_signature<R(Args...) & noexcept> : true_type |
| 192 | +{ |
| 193 | +}; |
| 194 | + |
| 195 | +# endif // defined(ASIO_HAS_NOEXCEPT_FUNCTION_TYPE) |
| 196 | + |
| 197 | +template <typename... Signatures> |
| 198 | +struct are_any_lvalue_completion_signatures : false_type |
| 199 | +{ |
| 200 | +}; |
| 201 | + |
| 202 | +template <typename Sig0> |
| 203 | +struct are_any_lvalue_completion_signatures<Sig0> |
| 204 | + : is_lvalue_completion_signature<Sig0> |
| 205 | +{ |
| 206 | +}; |
| 207 | + |
| 208 | +template <typename Sig0, typename... SigN> |
| 209 | +struct are_any_lvalue_completion_signatures<Sig0, SigN...> |
| 210 | + : integral_constant<bool, ( |
| 211 | + is_lvalue_completion_signature<Sig0>::value |
| 212 | + || are_any_lvalue_completion_signatures<SigN...>::value)> |
180 | 213 | {
|
181 | 214 | };
|
182 | 215 |
|
183 | 216 | template <typename T>
|
184 |
| -struct simple_completion_signature; |
| 217 | +struct is_rvalue_completion_signature : false_type |
| 218 | +{ |
| 219 | +}; |
185 | 220 |
|
186 | 221 | template <typename R, typename... Args>
|
187 |
| -struct is_simple_completion_signature<R(Args...)> : true_type |
| 222 | +struct is_rvalue_completion_signature<R(Args...) &&> : true_type |
188 | 223 | {
|
189 | 224 | };
|
190 | 225 |
|
| 226 | +# if defined(ASIO_HAS_NOEXCEPT_FUNCTION_TYPE) |
| 227 | + |
| 228 | +template <typename R, typename... Args> |
| 229 | +struct is_rvalue_completion_signature<R(Args...) && noexcept> : true_type |
| 230 | +{ |
| 231 | +}; |
| 232 | + |
| 233 | +# endif // defined(ASIO_HAS_NOEXCEPT_FUNCTION_TYPE) |
| 234 | + |
191 | 235 | template <typename... Signatures>
|
192 |
| -struct are_simple_completion_signatures : false_type |
| 236 | +struct are_any_rvalue_completion_signatures : false_type |
193 | 237 | {
|
194 | 238 | };
|
195 | 239 |
|
196 | 240 | template <typename Sig0>
|
197 |
| -struct are_simple_completion_signatures<Sig0> |
198 |
| - : is_simple_completion_signature<Sig0> |
| 241 | +struct are_any_rvalue_completion_signatures<Sig0> |
| 242 | + : is_rvalue_completion_signature<Sig0> |
199 | 243 | {
|
200 | 244 | };
|
201 | 245 |
|
202 | 246 | template <typename Sig0, typename... SigN>
|
203 |
| -struct are_simple_completion_signatures<Sig0, SigN...> |
| 247 | +struct are_any_rvalue_completion_signatures<Sig0, SigN...> |
204 | 248 | : integral_constant<bool, (
|
205 |
| - is_simple_completion_signature<Sig0>::value |
206 |
| - && are_simple_completion_signatures<SigN...>::value)> |
| 249 | + is_rvalue_completion_signature<Sig0>::value |
| 250 | + || are_any_rvalue_completion_signatures<SigN...>::value)> |
207 | 251 | {
|
208 | 252 | };
|
209 | 253 |
|
| 254 | +template <typename T> |
| 255 | +struct simple_completion_signature; |
| 256 | + |
210 | 257 | template <typename R, typename... Args>
|
211 | 258 | struct simple_completion_signature<R(Args...)>
|
212 | 259 | {
|
@@ -344,15 +391,17 @@ template <typename CompletionToken,
|
344 | 391 | ASIO_COMPLETION_SIGNATURE... Signatures>
|
345 | 392 | class async_result :
|
346 | 393 | public conditional_t<
|
347 |
| - detail::are_simple_completion_signatures<Signatures...>::value, |
| 394 | + detail::are_any_lvalue_completion_signatures<Signatures...>::value |
| 395 | + || !detail::are_any_rvalue_completion_signatures<Signatures...>::value, |
348 | 396 | detail::completion_handler_async_result<CompletionToken, Signatures...>,
|
349 | 397 | async_result<CompletionToken,
|
350 | 398 | typename detail::simple_completion_signature<Signatures>::type...>
|
351 | 399 | >
|
352 | 400 | {
|
353 | 401 | public:
|
354 | 402 | typedef conditional_t<
|
355 |
| - detail::are_simple_completion_signatures<Signatures...>::value, |
| 403 | + detail::are_any_lvalue_completion_signatures<Signatures...>::value |
| 404 | + || !detail::are_any_rvalue_completion_signatures<Signatures...>::value, |
356 | 405 | detail::completion_handler_async_result<CompletionToken, Signatures...>,
|
357 | 406 | async_result<CompletionToken,
|
358 | 407 | typename detail::simple_completion_signature<Signatures>::type...>
|
|
0 commit comments