名前空間
変種
操作

std::future_error

From cppreference.com
< cpp‎ | thread
 
 
並行性サポートライブラリ
スレッド
(C++11)
(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++20)
(C++20)
future
(C++11)
(C++11)
(C++11)
(C++11)
future_error
(C++11)
安全なメモリ解放 (Safe Reclamation)
(C++26)
ハザードポインタ
アトミック型
(C++11)
(C++20)
アトミック型の初期化
(C++11)(C++20で非推奨)
(C++11)(C++20で非推奨)
メモリオーダー
(C++11)(C++26で非推奨)
アトミック操作のためのフリー関数
アトミックフラグのためのフリー関数
 
 
ヘッダ <future> で定義
class future_error;
(C++11以降)

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

cpp/error/exceptioncpp/error/logic errorstd-future error-inheritance.svg

継承図

目次

[編集] メンバ関数

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 の仮想 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"

[編集] 関連項目

futureエラーコードを識別する
(enum) [編集]
English 日本語 中文(简体) 中文(繁體)