std:: future_error
From ja.cppreference.net
C++
Concurrency support library
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
std::future_error
|
定義済みヘッダー
<future>
|
||
|
class
future_error
;
|
(C++11以降) | |
クラス std::future_error は、非同期実行と共有状態を扱うスレッドライブラリの関数( std::future 、 std::promise など)が失敗した際にスローされる例外オブジェクトを定義します。 std::system_error と同様に、この例外は std::error_code と互換性のあるエラーコードを保持します。
継承図
目次 |
メンバー関数
std::future_errorオブジェクトを生成する
(public member function) |
|
std::future_errorオブジェクトを置き換える
(public member function) |
|
|
エラーコードを返す
(public member function) |
|
|
エラーコード固有の説明文字列を返す
(public member function) |
std:: logic_error から継承
std::exception から継承
メンバ関数
|
[仮想]
|
例外オブジェクトを破棄する
( std::exception の仮想公開メンバ関数)
|
|
[仮想]
|
説明文字列を返す
( std::exception の仮想公開メンバ関数)
|
例
このコードを実行
#include <future> #include <iostream> int main() { std::future<int> empty; try { int n = empty.get(); // 動作は未定義だが、 // 一部の実装では std::future_error をスローする } catch (const std::future_error& e) { std::cout << "Caught a future_error with code \"" << e.code() << "\"\nMessage: \"" << e.what() << "\"\n"; } }
出力例:
Caught a future_error with code "future:3" Message: "No associated state"
関連項目
|
(C++11)
|
フューチャーエラーコードを識別する
(列挙型) |