boost::asio::use_future_t
A completion_token type that causes an asynchronous operation to return a future.
Synopsis
Declared in <boost/asio/use_future.hpp>
template<typename Allocator = std::allocator<void>>
class use_future_t;
Types
Name |
Description |
The allocator type. The allocator is used when constructing the |
Member Functions
Name |
Description |
|
Constructors |
Obtain allocator. |
|
Wrap a function object in a packaged task. |
|
Specify an alternate allocator. |
Description
The use_future_t class is a completion token type that is used to indicate that an asynchronous operation should return a std::future object. A use_future_t object may be passed as a completion token 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.
Created with MrDocs