Commit 5953eb3
committed
asioexec::completion_token & ::use_sender: Constrain Initiate
Previously async_result<asioexec::completion_token, ...>:: and
async_result<asioexec::use_sender, ...>::initiate:
- Used automatic return type deduction, and
- Were not constrained on any properties of the arguments thereto
This meant that initiating functions of the form were problematic:
template <typename AsyncReadStream, typename Allocator,
BOOST_ASIO_COMPLETION_TOKEN_FOR(void (boost::system::error_code,
std::size_t)) ReadToken = default_completion_token_t<
typename AsyncReadStream::executor_type>>
inline auto async_read(AsyncReadStream& s, basic_streambuf<Allocator>& b,
ReadToken&& token = default_completion_token_t<
typename AsyncReadStream::executor_type>(),
constraint_t<
!is_completion_condition<ReadToken>::value
> = 0)
-> decltype(
async_initiate<ReadToken,
void (boost::system::error_code, std::size_t)>(
declval<detail::initiate_async_read_dynbuf_v1<AsyncReadStream>>(),
token, basic_streambuf_ref<Allocator>(b), transfer_all()));
Note that:
- The above is an actual initiating function from Asio, and
- The return type is defined in terms of the type returned by
async_initiate
The latter of the two points above means that the compiler must
determine the type of an expression involving async_initiate. Since that
expression transitively defers to async_result<...>::initiate this meant
that the compiler had to determine the return type thereof. Since (as
mentioned above) that function uses automatic return type deduction that
meant the compiler had to substitute into the body thereof. Since errors
in such a context are not SFINAE-friendly this meant that if the
variadic pack of arguments thereto did not consist only of decay-
copyable types there would be a hard compilation error (rather than the
overload simply being removed from the candidate set).
Both newly-added unit tests failed to compile before this change due to
the above.
Added a constraint to both previously-mentioned initiate functions to
address the above.1 parent 05edd1a commit 5953eb3
File tree
4 files changed
+39
-0
lines changed- include/asioexec
- test/asioexec
4 files changed
+39
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
527 | 527 | | |
528 | 528 | | |
529 | 529 | | |
| 530 | + | |
530 | 531 | | |
531 | 532 | | |
532 | 533 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
212 | 212 | | |
213 | 213 | | |
214 | 214 | | |
| 215 | + | |
215 | 216 | | |
216 | 217 | | |
217 | 218 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
997 | 997 | | |
998 | 998 | | |
999 | 999 | | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
| 1014 | + | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
1000 | 1021 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
250 | 250 | | |
251 | 251 | | |
252 | 252 | | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
253 | 269 | | |
0 commit comments