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 an older version of Boost and was released in 2018. The current version is 1.90.0.
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.
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();