...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
Class used to specify that an asynchronous operation should return a future.
template< typename Allocator = std::allocator<void>> class use_future_t
Name |
Description |
---|---|
The allocator type. The allocator is used when constructing the std::promise object for a given asynchronous operation. |
Name |
Description |
---|---|
Obtain allocator. |
|
Wrap a function object in a packaged task. |
|
(Deprecated: Use rebind().) Specify an alternate allocator. |
|
Specify an alternate allocator. |
|
Construct using default-constructed allocator. |
The use_future_t
class is used to indicate that an asynchronous operation should return a
std::future object. A use_future_t
object may be passed as a handler to an asynchronous operation, typically
using the special value boost::asio::use_future
. For example:
std::future<std::size_t> my_future = my_socket.async_read_some(my_buffer, boost::asio::use_future);
The initiating function (async_read_some in the above example) returns a future that will receive the result of the operation. If the operation completes with an error_code indicating failure, it is converted into a system_error and passed back to the caller via the future.
Header: boost/asio/use_future.hpp
Convenience header: boost/asio.hpp