std::logic_error
提供: cppreference.com
ヘッダ <stdexcept> で定義 | ||
class logic_error; | ||
例外として投げるためのオブジェクトの型を定義します。 論理的な事前条件やクラスの不変条件の違反のようなプログラム内のロジックの誤りの結果であり回避できるかもしれないエラーを報告します。
この例外を直接投げる標準ライブラリのコンポーネントはありませんが、例外型 std::invalid_argument, std::domain_error, std::length_error, std::out_of_range, std::future_error, std::experimental::bad_optional_access は std::logic_error
から派生しています。
目次 |
[編集]メンバ関数
コンストラクタ | 例外オブジェクトを構築します (パブリックメンバ関数) |
std::logic_error::logic_error
explicit logic_error(conststd::string& what_arg ); | (1) | |
explicit logic_error(constchar* what_arg ); | (2) | (C++11以上) |
what() でアクセス可能な説明文字列として what_arg
を持つ例外オブジェクトを構築します。
std::logic_error
のコピーが例外を投げることは許されないため、このメッセージは内部的には一般的に別に確保された参照カウント管理の文字列として格納されます。 これは std::string&&
を取るコンストラクタが無い理由でもあります。 どのみち内容をコピーしなければならないのです。
引数
what_arg | - | 説明文字列 |
例外
std::bad_alloc を投げる場合があります
std::exception から継承
メンバ関数
[仮想] | 例外オブジェクトを破棄します ( std::exception の仮想パブリックメンバ関数) |
[仮想] | 説明文字列を返します ( std::exception の仮想パブリックメンバ関数) |