std::future_error
提供: cppreference.com
ヘッダ <future> で定義
|
||
class future_error; |
(C++11以上) | |
クラス std::future_error は非同期実行および共有状態 (std::future, std::promise など) を扱うスレッドライブラリの関数によって失敗時に投げられる例外オブジェクトを定義します。 std::system_error と同様に、この例外は std::error_code と互換性のあるエラーコードを持ち運びます。
目次 |
[編集] メンバ関数
std::future_error オブジェクトを作成します (パブリックメンバ関数) | |
エラーコードを返します (パブリックメンバ関数) | |
エラーコードに固有の説明文字列を返します (パブリックメンバ関数) |
std::logic_error から継承
std::exception から継承
メンバ関数
[仮想] |
例外オブジェクトを破棄します ( std::exception の仮想パブリックメンバ関数)
|
[仮想] |
説明文字列を返します ( std::exception の仮想パブリックメンバ関数)
|
[編集] 例
Run this code
#include <future> #include <iostream> int main() { std::future<int> empty; try { int n = empty.get(); // The behavior is undefined, but // some implementations throw 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) |
フューチャーのエラーコードを識別します (列挙) |