Networking TS

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.

rebind

Specify an alternate allocator.

use_future_t

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 std::experimental::net::v1::use_future. For example:

std::future<std::size_t> my_future
  = my_socket.async_read_some(my_buffer, std::experimental::net::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.


PrevUpHomeNext