std::future<T>::share
來自 cppreference.com
std::shared_future<T> share() noexcept; |
||
將 *this 的共享狀態(如果有)轉移到一個 std::shared_future 物件。多個 std::shared_future 物件可以引用同一個共享狀態,這對於 std::future 是不可能的。
在 std::future 上呼叫 share
後,valid() == false。
目錄 |
[編輯] 引數
(無)
[編輯] 返回值
一個 std::shared_future 物件,包含先前由 *this 持有的共享狀態(如果有),如同透過 std::shared_future<T>(std::move(*this)) 構造。
[編輯] 示例
本節不完整 原因:無示例 |
[編輯] 缺陷報告
下列更改行為的缺陷報告追溯地應用於以前出版的 C++ 標準。
缺陷報告 | 應用於 | 釋出時的行為 | 正確的行為 |
---|---|---|---|
LWG 2556 | C++11 | share() 要求 valid() 為 true |
要求已移除並變為 noexcept |
[編輯] 另請參閱
(C++11) |
等待一個非同步設定的值(可能被其他 future 引用) (類模板) |