CppDS.com

C++ 98 11 14 17 20 手册

std::experimental::shared_future<T>::shared_future

来自cppreference.com

shared_future() noexcept;
(1)
shared_future(std::experimental::shared_future<T>&& f) noexcept;
(2)
shared_future(const std::experimental::shared_future<T>& f);
(3)
shared_future(std::experimental::future<std::experimental::shared_future<T>> && other) noexcept;
(4)
shared_future(std::experimental::future<T>&& f) noexcept;
(5)
1) 默认构造函数。构造不指代共享状态的空 shared_future 对象。
2) 构造 shared_future ,转移 f 所保有的共享状态,若存在。构造后 f.valid()false
3) 构造 shared_future ,与 f 指代同一共享状态,若共享状态存在。
4)other 所指代的共享状态构造 shared_future 对象。结果 shared_future 的对象在下列之一发生时变为就绪:
  • otherother.get() 均就绪。存储来自 other.get() 的值或异常到与结果 shared_future 状态关联的共享状态中。
  • other 就绪,但 other.get() 非法。存储以 std::future_errc::broken_promise 为错误条件的 std::future_error 类型异常到与结果 shared_future 对象关联的共享状态中。
此构造函数返回后, valid() == trueother.valid() == false
5) 构造 shared_future 对象,转移 f 所保有的共享状态,若存在。构造后 f.valid()false

参数

f - 用以初始化的另一 future 对象
other - 要解包装的 std::experimental::future 对象

示例

参阅

构造 future 对象
(std::shared_future<T> 的公开成员函数)
关闭