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 an old version of Boost. Click here to view this page for the latest version.
PrevUpHomeNext

use_future_t

Class used to specify that an asynchronous operation should return a future.

template<
    typename Allocator = std::allocator<void>>
class use_future_t
Types

Name

Description

allocator_type

The allocator type. The allocator is used when constructing the std::promise object for a given asynchronous operation.

Member Functions

Name

Description

get_allocator

Obtain allocator.

operator()

Wrap a function object in a packaged task.

operator[]

(Deprecated: Use rebind().) Specify an alternate allocator.

rebind

Specify an alternate allocator.

use_future_t [constructor]

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 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.

Requirements

Header: boost/asio/use_future.hpp

Convenience header: boost/asio.hpp


PrevUpHomeNext