Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add experimental::as_single completion token adapter.
The as_single completion token adapter can be used to specify that the completion handler arguments should be combined into a single argument. For completion signatures with a single parameter, the argument is passed through as-is. For signatures with two or more parameters, the arguments are combined into a tuple. The as_single adapter may be used in conjunction with use_awaitable and structured bindings as follows: auto [e, n] = co_await socket.async_read_some( boost::asio::buffer(data), as_single(use_awaitable)); Alternatively, it may be used as a default completion token like so: using default_token = as_single_t<use_awaitable_t<>>; using tcp_socket = default_token::as_default_on_t<tcp::socket>; // ... awaitable<void> do_read(tcp_socket socket) { // ... auto [e, n] = co_await socket.async_read_some(boost::asio::buffer(data)); // ... }
- Loading branch information