名前空間
変種
操作

std::future_error

提供: cppreference.com
< cpp‎ | thread
 
 
スレッドサポートライブラリ
スレッド
(C++11)
(C++20)
(C++20)
this_thread 名前空間
(C++11)
(C++11)
(C++11)
相互排他
(C++11)
汎用ロック管理
(C++11)
(C++11)
(C++11)
(C++11)(C++11)(C++11)
(C++11)
(C++11)
条件変数
(C++11)
セマフォ
ラッチとバリア
(C++20)
(C++20)
フューチャー
(C++11)
(C++11)
(C++11)
(C++11)
future_error
(C++11)
 
 
ヘッダ <future> で定義
class future_error;
(C++11以上)

クラス std::future_error は非同期実行および共有状態 (std::future, std::promise など) を扱うスレッドライブラリの関数によって失敗時に投げられる例外オブジェクトを定義します。 std::system_error と同様に、この例外は std::error_code と互換性のあるエラーコードを持ち運びます。

cpp/error/exceptioncpp/error/logic errorstd-future error-inheritance.svg
画像の詳細

継承図

目次

[編集] メンバ関数

std::future_error オブジェクトを作成します
(パブリックメンバ関数) [edit]
エラーコードを返します
(パブリックメンバ関数) [edit]
エラーコードに固有の説明文字列を返します
(パブリックメンバ関数) [edit]

std::logic_error から継承

std::exception から継承

メンバ関数

例外オブジェクトを破棄します
(std::exceptionの仮想パブリックメンバ関数) [edit]
[仮想]
説明文字列を返します
(std::exceptionの仮想パブリックメンバ関数) [edit]

[編集]

#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"

[編集] 関連項目

フューチャーのエラーコードを識別します
(列挙) [edit]