Namespaces
Variants

std::contracts::contract_violation

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で非推奨)
 
 
ヘッダで定義<contracts>
class contract_violation;
(C++26以上)

クラス std::contracts::contract_violation は、特定の評価セマンティクスを持つ contract assertion の評価中に検出された契約違反を表現するために使用されるオブジェクトの型を定義します。

この型のオブジェクトは、実装によってのみ作成され、契約違反ハンドラを呼び出す必要がある場合に作成されます。ユーザーは直接そのようなオブジェクトを作成できません。

メンバー関数

(constructor)
[deleted]
contract_violation オブジェクトはユーザーによって構築できない
(public member function)
operator=
[deleted]
contract_violation オブジェクトは代入できない
(public member function)
(destructor)
[possibly virtual]
contract_violation オブジェクトを破棄する
(public member function)
一般的な契約違反情報
kind
違反された契約表明の種類を返す
(public member function)
semantic
契約違反が発生したときの評価セマンティクスを返す
(public member function)
is_terminating
評価セマンティクスが終了するかどうかを返す
(public member function)
detection_mode
契約違反の原因となった理由を返す
(public member function)
evaluation_exception
述語評価からスローされた例外への std::exception_ptr を返す
(public member function)
その他の契約違反情報
comment
契約違反についての説明文字列を返す
(public member function)
location
契約違反の位置を示す std::source_location を返す
(public member function)

std::contracts::contract_violation:: contract_violation

contract_violation ( const contract_violation & ) = delete ;
(C++26以降)

コピーコンストラクタは削除定義されています。 std::contracts::contract_violation は CopyConstructible の要件を満たしません。

注記

その他のコンストラクタは内部使用専用であり、ユーザーからはアクセスできません。

std::contracts::contract_violation:: operator=

contract_violation & operator = ( const contract_violation & ) = delete ;
(C++26以降)

コピー代入演算子は削除済みとして定義されています。 std::contracts::contract_violation は CopyAssignable の要件を満たしません。

std::contracts::contract_violation:: ~contract_violation

/* see below */ ~contract_violation ( ) ;
(C++26 以降)

contract_violation オブジェクトを破棄します。

注記

デストラクタが仮想関数かどうかは実装定義です。

std::contracts::contract_violation:: kind

std :: contracts :: assertion_kind kind ( ) const noexcept ;
(C++26以降)

戻り値

違反された契約表明の構文形式に対応する列挙子の値を返します。

std::contracts::contract_violation:: semantic

std :: contracts :: evaluation_semantic semantic ( ) const noexcept ;
(C++26以降)

戻り値

違反された契約アサーションが評価された評価セマンティクスに対応する列挙子の値を返します。

std::contracts::contract_violation:: is_terminating

bool is_terminating ( ) const noexcept ;
(C++26以降)

戻り値

評価セマンティクスが 終了セマンティクス の場合、 true を返す。それ以外の場合は false を返す。

std::contracts::contract_violation:: detection_mode

std :: contracts :: detection_mode detection_mode ( ) const noexcept ;
(C++26以降)

戻り値

契約違反の原因となった理由に対応する列挙子の値を返します。

std::contracts::contract_violation:: comment

const char * comment ( ) const noexcept ;
(C++26以降)

戻り値

契約違反が述語の評価が例外によって終了したために発生した場合、その例外またはその例外のコピーを参照する std::exception_ptr オブジェクトを返します。それ以外の場合、nullの std::exception_ptr オブジェクトを返します。

注記

C++標準では、返される文字列は違反した契約表明の述語のテキスト表現を含むか、テキスト表現の保存が望ましくない場合は空文字列を含むことを推奨している。

std::contracts::contract_violation:: location

std:: source_location location ( ) const noexcept ;
(C++26以降)

戻り値

ナル終端マルチバイト文字列 を 通常リテラルエンコーディング で実装定義の内容で返す。

注記

C++標準では、返される値はデフォルト構築された std::source_location オブジェクト、または違反した契約アサーションを識別する値であることが推奨されています:

  • 可能な場合、違反した契約アサーションが 事前条件アサーション であった場合、関数呼び出しのソースロケーションが返されるべきです。
  • それ以外の場合、契約アサーションのソースロケーションが返されるべきです。