std::future_error
From cppreference.com
| ヘッダ <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 から継承
メンバ関数
| [virtual] |
例外オブジェクトを破棄する ( std::exception の仮想 public メンバー関数) |
| [virtual] |
説明文字列を返す ( std::exception の仮想 public メンバー関数) |
[編集] 例
このコードを実行
#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) |
futureエラーコードを識別する (enum) |