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. |
|
Specify an alternate allocator. |
|
Construct using default-constructed allocator. Construct using specified 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
asio::use_future
. For example:
std::future<std::size_t> my_future = my_socket.async_read_some(my_buffer, 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: asio/use_future.hpp
Convenience header: None