◐ Shell
clean mode source ↗

std::logic_error - cppreference.com

提供: cppreference.com

<tbody> </tbody>

例外として投げるためのオブジェクトの型を定義します。 論理的な事前条件やクラスの不変条件の違反のようなプログラム内のロジックの誤りの結果であり回避できるかもしれないエラーを報告します。

この例外を直接投げる標準ライブラリのコンポーネントはありませんが、例外型 std::invalid_argument, std::domain_error, std::length_error, std::out_of_range, std::future_error, std::experimental::bad_optional_accessstd::logic_error から派生しています。

cpp/error/exception

継承図

メンバ関数

std::logic_error::logic_error

<tbody> </tbody>

explicit logic_error( const std::string& what_arg );

(1)

explicit logic_error( const char* what_arg );

(2) (C++11以上)

what() でアクセス可能な説明文字列として what_arg を持つ例外オブジェクトを構築します。

std::logic_error のコピーが例外を投げることは許されないため、このメッセージは内部的には一般的に別に確保された参照カウント管理の文字列として格納されます。 これは std::string&& を取るコンストラクタが無い理由でもあります。 どのみち内容をコピーしなければならないのです。

引数

例外

std::bad_alloc を投げる場合があります