asio/example
Christopher Kohlhoff 8e0762de49 Add default completion tokens.
Every I/O executor type now has an associated default completion token
type. This is specified via the `default_completion_token_type` trait.
This trait may be used in asynchronous operation declarations as
follows:

  template <
      typename IoObject,
      typename CompletionToken =
        typename default_completion_token_type<
          typename IoObject::executor_type
        >::type
    >
  auto async_foo(
      IoObject& io_object,
      CompletionToken&& token =
        typename default_completion_token_type<
          typename IoObject::executor_type
        >::type{}
    );

If not specialised, this trait type is `void`, meaning no default
completion token type is available for the given I/O executor.

The `default_completion_token_type` trait is specialised for the
`use_awaitable` completion token so that it may be used as shown in the
following example:

  auto socket = use_awaitable.as_default_on(tcp::socket(my_context));
  // ...
  co_await socket.async_connect(my_endpoint); // Defaults to use_awaitable.

In this example, type of the `socket` object is transformed from
`tcp::socket` to have an I/O executor with the default completion token
set to `use_awaitable`.

Alternatively, the socket type may be computed directly:

  using tcp_socket = use_awaitable_t<>::as_default_on_t<tcp::socket>;
  tcp_socket socket(my_context);
  // ...
  co_await socket.async_connect(my_endpoint); // Defaults to use_awaitable.
2019-10-30 20:51:58 +11:00
..
cpp03 Fix doxygen generation in tutorial. 2019-07-09 19:20:10 +10:00
cpp11 Suppress various unused variable warnings. 2019-03-07 16:18:56 +11:00
cpp14/operations Update composed operations examples to use async_initiate and a new helper function async_compose. 2019-03-06 20:22:23 +11:00
cpp17/coroutines_ts Add default completion tokens. 2019-10-30 20:51:58 +11:00