Namespaces
Variants

std::bad_expected_access

ja.cppreference.net より
 
 
ユーティリティライブラリ
言語サポート
型サポート (基本型、RTTI)
ライブラリ機能テストマクロ (C++20)
プログラムユーティリティ
可変長引数関数
コルーチンサポート (C++20)
契約サポート (C++26)
三方比較
(C++20)
(C++20)(C++20)(C++20)    
(C++20)(C++20)(C++20)

汎用ユーティリティ
関係演算子 (C++20で非推奨)
整数比較関数
(C++20)(C++20)(C++20)    
(C++20)
swap と 型操作
(C++14)
(C++11)
(C++11)
(C++11)
(C++17)
共通の語彙型
(C++11)
(C++17)
(C++17)
(C++17)
(C++11)
(C++17)
(C++23)



 
 
ヘッダ <expected>
template< class E >
class bad_expected_access : public std::bad_expected_access<void>
で定義 (1) (C++23以上)
template<>
class bad_expected_access<void> : public std::exception
(2) (C++23以上)
1) 保持している値がエラー値である expected オブジェクトにアクセスした際に std::expected::value によって投げられるオブジェクトの型を定義します。 bad_expected_access<E> はエラー値のコピーを格納します。
2) bad_expected_access<void> はそれ以外の全ての bad_expected_access 特殊化の基底クラスです。

プライマリテンプレートのメンバー

(constructor)
bad_expected_accessオブジェクトを構築する
(public member function)
error
格納された値を返す
(public member function)
what
説明文字列を返す
(public member function)

std::bad_expected_access:: bad_expected_access

explicit bad_expected_access ( E e ) ;
(C++23以降)
(C++26以降 constexpr)

新しいbad_expected_access<E>オブジェクトを構築します。 格納された値をstd::move(e)で初期化します。

std::bad_expected_access:: error

const E & error ( ) const & noexcept ;
(1) (C++23以降)
(C++26以降 constexpr)
E & error ( ) & noexcept ;
(2) (C++23以降)
(C++26以降 constexpr)
const E && error ( ) const && noexcept ;
(3) (C++23以降)
(C++26以降 constexpr)
E && error ( ) && noexcept ;
(4) (C++23以降)
(C++26以降 constexpr)

格納された値への参照を返します。

std::bad_expected_access:: what

const char * what ( ) const noexcept override ;
(C++23以降)
(constexpr since C++26)

説明文字列を返します。

パラメータ

(なし)

戻り値

説明情報を含むヌル終端文字列へのポインタ。この文字列は std::wstring への変換と表示に適しています。ポインタは、少なくとも取得元の例外オブジェクトが破棄されるまで、または例外オブジェクトの非constメンバー関数(コピー代入演算子など)が呼び出されるまで有効であることが保証されています。

定数評価中、返される文字列は通常のリテラルエンコーディングでエンコードされます。

(C++26以降)

注記

実装は what() をオーバーライドすることが許可されていますが、必須ではありません。

bad_expected_access < void > 特殊化のメンバー

(コンストラクタ)
bad_expected_access < void > オブジェクトを構築
(protected メンバー関数)
(デストラクタ)
bad_expected_access < void > オブジェクトを破棄
(protected メンバー関数)
operator=
bad_expected_access < void > オブジェクトを置換
(protected メンバー関数)
what
説明文字列を返す
(public メンバー関数)

bad_expected_access < void > の特殊メンバー関数は protected です。派生クラスからのみ呼び出すことができます。

例