std::future_error - cppreference.com
提供: cppreference.com
<tbody> </tbody>
|
|
(C++11以上) | |
クラス std::future_error は非同期実行および共有状態 (std::future, std::promise など) を扱うスレッドライブラリの関数によって失敗時に投げられる例外オブジェクトを定義します。 std::system_error と同様に、この例外は std::error_code と互換性のあるエラーコードを持ち運びます。
継承図
メンバ関数
std::logic_error から継承
例
#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"