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
std::experimental::future
or std::experimental::shared_future
supplied to
this constructor becomes ready, and a call to
f.valid()
on the stored std::experimental::shared_future
object returns
false
, or
std::experimental::future
or std::experimental::shared_future
supplied to
this constructor becomes ready, a call to f.valid()
on the stored std::experimental::shared_future
object returns
true
, and that nested
std::experimental::shared_future
itself becomes
ready.
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);
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
.
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.
std::bad_alloc
if memory for the new
asynchronous state could not be allocated.
#include <experimental/future>