16 Language support library [language.support]

16.8 Contract violation handling [support.contract]

16.8.1 Header <contract> synopsis [contract.syn]

The header <contract> defines a type for reporting information about contract violations generated by the implementation.
namespace std {
  class contract_violation;
}

16.8.2 Class contract_­violation [support.contract.cviol]

namespace std {
  class contract_violation {
  public:
    uint_least32_t line_number() const noexcept;
    string_view file_name() const noexcept;
    string_view function_name() const noexcept;
    string_view comment() const noexcept;
    string_view assertion_level() const noexcept;
  };
}
The class contract_­violation describes information about a contract violation generated by the implementation.
uint_least32_t line_number() const noexcept;
Returns: The source code location where the contract violation happened ([dcl.attr.contract]).
If the location is unknown, an implementation may return 0.
string_view file_name() const noexcept;
Returns: The source file name where the contract violation happened ([dcl.attr.contract]).
If the file name is unknown, an implementation may return string_­view{}.
string_view function_name() const noexcept;
Returns: The name of the function where the contract violation happened ([dcl.attr.contract]).
If the function name is unknown, an implementation may return string_­view{}.
string_view comment() const noexcept;
Returns: Implementation-defined text describing the predicate of the violated contract.
string_view assertion_level() const noexcept;
Returns: Text describing the assertion-level of the violated contract.