public member function


default (1)
shared_future() noexcept;
copy (2)
shared_future (const shared_future& x);
move (3)
shared_future (shared_future&& x) noexcept;
move from future (4)
shared_future (future<T>&& x) noexcept;
Construct shared_future
Constructs a shared_future object:

(1) default constructor
Constructs an empty shared_future: The object has no shared state, and thus is not valid, but it can be assigned a valid value.
(2) copy constructor
The constructed shared_future has the same shared state as x, with which it shares ownership.
(3) (4) move constructors
The constructed object acquires the shared state of x (if any).
x is left with no shared state (it is no longer valid).

Shared futures with valid shared states are obtained from future objects, either by using the move constructor (4) or by calling member future::share.


Another shared_future object of the same type (with the same template parameter, T).
Or, for (4), a future object with the same template parameter (T).

Data races

The move constructors (3) and (4) modify x.

Exception safety

Copying a shared_future object (2) that is not valid, produces undefined behavior (although library implementations may detect this and throw future_error with a no_state error condition).

For the other constructors, shared_future constructors never throw exceptions (no-throw guarantee).

See also