std::future::share

std::shared_future<T> share() noexcept;

转移 *this 的共享状态,若存在,到 std::shared_future 对象。多个 std::shared_future 对象可引用同一共享对象,这对于 std::future 不可能。

std::future 上调用 sharevalid() == false

目录

参数

(无)

返回值

含有先前 *this 所保有的共享状态(若存在)的 std::shared_future 对象,如同以 std::shared_future<T>(std:move(*this)) 构造。

示例

缺陷报告

下列更改行为的缺陷报告追溯地应用于以前出版的 C++ 标准。

DR 应用于 出版时的行为 正确行为
LWG 2556 C++11 share() 要求 valid()true 移除要求并使之为 noexcept

参阅

等待被异步设置的值(可能为其他 future 所引用)
(类模板)

版本历史

  • (当前 | 先前 2017年9月24日 (日) 09:34Fruderica讨论 | 贡献. . (1,043字节) (-423). . (撤销)
  • 当前 | 先前 2013年7月2日 (二) 11:31P12bot讨论 | 贡献 . . (1,466字节) (-15). . (Use {{lc}}. Update links. Various fixes.) (撤销)
  • 当前 | 先前 2012年11月2日 (五) 20:02P12bot讨论 | 贡献 . . (1,481字节) (+249). . (r2.7.3) (机器人添加:de, en, es, fr, it, ja, pt, ru) (撤销)
  • 当前 | 先前 2012年10月26日 (五) 03:08P12讨论 | 贡献 . . (1,232字节) (0). . (1个修订: Translate from the English version) (撤销)
  • 当前 | 先前) 2012年10月25日 (四) 12:00TranslationBot讨论 | 贡献. . (1,232字节) (+1,232). . (Translated from the English version using Google Translate)