Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for a snapshot of the develop branch, built from commit b45a890ece.
PrevUpHomeNext

use_future_t::operator()

Wrap a function object in a packaged task.

template<
    typename Function>
unspecified operator()(
    Function && f) const;

The package function is used to adapt a function object as a packaged task. When this adapter is passed as a completion token to an asynchronous operation, the result of the function object is retuned via a std::future.

Example
std::future<std::size_t> fut =
  my_socket.async_read_some(buffer,
    use_future([](boost::system::error_code ec, std::size_t n)
      {
        return ec ? 0 : n;
      }));
...
std::size_t n = fut.get();

PrevUpHomeNext