future
future is a type that can be used to await a value from the promise. The
stored data is only destroyed when the promise, and all associated futures
go out of scope.
Prototype
template <typename T, typename Allocator>
struct future {
friend void swap(future &a, future &b); // (1)
future(Allocator allocator = {}); // (2)
future(const future &); // (3)
future(future &&); // (4)
future &operator=(const future &); // (3)
future &operator=(future &&); // (4)
sender get(cancellation_token ct); // (5)
sender get(); // (6)
bool valid(); // (7)
operator bool (); // (7)
};
- Swaps two futures.
- Constructs an empty future.
- Copies a future. The copy of the future refers to the same state as the
original object in a manner similar to a
shared_ptr. - Moves a future.
- Asynchronously obtains the value.
- Same as (5).
- Checks whether the future has valid state.
Requirements
T is any type. Allocator is an allocator.
Arguments
ct- the cancellation token to use.
Return values
- This function doesn't return any value.
- N/A
- N/A for constructor, reference to this object for assignment operator.
- Same as (3).
- This method returns a sender of unspecified type. If
Tis notvoid, the sender returns a value of typefrg::optional<T *>. It returns the pointer if the value was obtained successfully,frg::null_optif the operation was cancelled. IfTisvoid, the sender returnstrueif the value was obtained successfully,falseif the operation was cancelled. - This method returns a sender of unspecified type. If
Tis notvoid, the sender returns a pointer to the stored value. IfTisvoid, it doesn't return anything. - These methods return
trueif the future has valid state,falseotherwise.