Namespaces
Variants

Standard library header <contracts> (C++26)

From cppreference.com
 
 
Standard library headers
 

This header is part of the language support library.

Types

Defined in namespace std::contracts
the kind of the contract assertion violated
(enum) [edit]
the evaluation semantic when the contract violation occurs
(enum) [edit]
the reason that causes the contract violation
(enum) [edit]
the type holding the contract-violation information
(class) [edit]

Functions

Defined in namespace std::contracts
invokes the default contract-violation handler
(function) [edit]

Synopsis

// all freestanding
namespace std::contracts {

  enum class assertion_kind :      /* unspecified */
  {
    pre = 1,
    post = 2,
    assert = 3
  };

  enum class evaluation_semantic : /* unspecified */
  {
    ignore = 1,
    observe = 2,
    enforce = 3,
    quick_enforce = 4
  };

  enum class detection_mode :      /* unspecified */
  {
    predicate_false = 1,
    evaluation_exception = 2
  };

  class contract_violation;

  void invoke_default_contract_violation_handler(const contract_violation&);
}

Class std::contracts::contract_violation

namespace std::contracts {
  class contract_violation
  {
    // no user-accessible constructor
  public:
    contract_violation(const contract_violation&) = delete;
    contract_violation& operator=(const contract_violation&) = delete;

    /* see description */ ~contract_violation();

    const char* comment() const noexcept;
    contracts::detection_mode detection_mode() const noexcept;
    bool is_terminating() const noexcept;
    assertion_kind kind() const noexcept;
    source_location location() const noexcept;
    evaluation_semantic semantic() const noexcept;
  };
}