Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

Nullary token requirements

A nullary token is a completion token for completion signature void().

Examples

A free function as a nullary token:

void nullary_handler()
{
  ...
}

A nullary token function object:

struct nullary_handler
{
  ...
  void operator()()
  {
    ...
  }
  ...
};

A lambda as a nullary token:

boost::asio::post(...,
    []()
    {
      ...
    });

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

void my_class::nullary_handler()
{
  ...
}
...
boost::asio::post(...,
    std::bind(&my_class::nullary_handler, this));

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

void my_class::nullary_handler()
{
  ...
}
...
boost::asio::post(...,
    boost::bind(&my_class::nullary_handler, this));

Using use_future as a nullary token:

std::future<void> f = boost::asio::post(..., boost::asio::use_future);
...
f.get();

Using use_awaitable as a nullary token:

boost::asio::awaitable<void> my_coroutine()
{
  ...
  co_await boost::asio::post(..., boost::asio::use_awaitable);
  ...
}

PrevUpHomeNext