public member function
<future>

std::shared_future::shared_future

默认 (1)
shared_future() noexcept;
复制 (2)
shared_future (const shared_future& x);
移动 (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) 默认构造函数
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.

参数

x
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).

数据竞争

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

异常安全

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).

另见