[/
 / Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff dot com)
 /
 / Distributed under the Boost Software License, Version 1.0. (See accompanying
 / file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
 /]

[section:ConnectToken Connect token requirements]

A connect token is a [link asio.overview.model.completion_tokens completion token]
for completion signature `void(error_code)`.

[heading Examples]

A free function as a connect token:

  void connect_handler(
      const asio::error_code& ec)
  {
    ...
  }

A connect token function object:

  struct connect_handler
  {
    ...
    void operator()(
        const asio::error_code& ec)
    {
      ...
    }
    ...
  };

A lambda as a connect token:

  socket.async_connect(...,
      [](const asio::error_code& ec)
      {
        ...
      });

A non-static class member function adapted to a connect token using
`std::bind()`:

  void my_class::connect_handler(
      const asio::error_code& ec)
  {
    ...
  }
  ...
  socket.async_connect(...,
      std::bind(&my_class::connect_handler,
        this, std::placeholders::_1));

A non-static class member function adapted to a connect token using
`boost::bind()`:

  void my_class::connect_handler(
      const asio::error_code& ec)
  {
    ...
  }
  ...
  socket.async_connect(...,
      boost::bind(&my_class::connect_handler,
        this, asio::placeholders::error));

Using [link asio.reference.use_future use_future] as a connect token:

  std::future<void> f = socket.async_connect(..., asio::use_future);
  ...
  try
  {
    f.get();
  }
  catch (const system_error& e)
  {
    ...
  }

Using [link asio.reference.use_awaitable use_awaitable] as a connect token:

  asio::awaitable<void> my_coroutine()
  {
    try
    {
      ...
      co_await socket.async_connect(..., asio::use_awaitable);
      ...
    }
    catch (const system_error& e)
    {
      ...
    }
  }

[endsect]
