Documentation Home >> Headers >> <jss/experimental_future.hpp> Header >> std::experimental::shared_future >> std::experimental::shared_future Unwrapping Constructor

Construct a std::experimental::shared_future object from a std::experimental::future or std::experimental::shared_future that holds a nested std::experimental::shared_future in its shared state. The new future becomes ready when either

In the former case, the newly-constructed future becomes ready with a stored exception of type std::future_error, with an error code of std::future_errc::broken_promise.

In the latter case, the newly-constructed future becomes ready with the stored value or exception from the nested future.

shared_future(future<shared_future<ResultType>>&& other);
shared_future(shared_future<shared_future<ResultType>> const& other);

Effects:

Constructs a new std::experimental::shared_future instance that unwraps the nested std::experimental::shared_future from other, such that *this is ready when both other and other.get() would be ready, or other is ready with a future for which valid() returns false.

Postconditions:

this->valid() returns the same value that other.valid() returned before the invocation of this constructor. For the overload that takes a std::experimental::future, other has no associated asynchronous result, and other.valid() returns false. For the overload that takes a std::experimental::shared_future, other is unchanged.

Throws:

std::bad_alloc if memory for the new asynchronous state could not be allocated.

Header

#include <experimental/future>

See Also