13 Asynchronous model [async]

13.26 Class template use_future_t [async.use.future]

13.26.2 use_future_t members [async.use.future.members]

template<class OtherProtoAllocator> use_future_t<OtherProtoAllocator> rebind(const OtherProtoAllocator& a) const noexcept;

Returns: A use_future_t object where get_allocator() == a.

allocator_type get_allocator() const noexcept;

Returns: The associated allocator object.

template <class F> unspecified operator()(F&& f) const;

Let T be a completion token type. Let H be a completion handler type and let h be an object of type H. Let FD be the type decay_t<F> and let fd be an lvalue of type FD constructed with std::forward<F>(f). Let R(Args...) be the completion signature of an asynchronous operation using H and let N be sizeof...(Args). Let i be in the range [0, N) and let Ai be the ith type in Args. Let ai be the argument associated with Ai.

Returns: A completion token t of type T.

Remarks: The return type T satisfies the Destructible (C++ 2014 [destructible]) and MoveConstructible (C++ 2014 [moveconstructible]) requirements.

The object h of type H is an asynchronous provider with an associated shared state (C++ 2014 [futures.state]). The effect of h(a0, ..., aN-1) is to atomically store the result of INVOKE(fd, forward<A0>(a0), ..., forward<AN-1>(aN-1)) (C++ 2014 [func.require]) in the shared state and make the shared state ready. If fd exits via an exception then that exception is atomically stored in the shared state and the shared state is made ready.

The implementation provides a partial specialization template <class Result, class... Args> async_result<T, Result(Args...)> such that:

  • the nested type completion_handler_type is a type H;

  • the nested type return_type is future<result_of_t<FD(decay_t<Args>...)>>; and

  • when an object r1 of type async_result<T, Result(Args...)> is constructed from h, the expression r1.get() returns a future with the same shared state as h.

For any executor type E, the associated object for the associator associated_executor<H, E> is an executor where, for function objects executed using the executor's dispatch(), post() or defer() functions, any exception thrown is caught by a function object and stored in the associated shared state.