Defined in header <contract> | ||
---|---|---|
class contract_violation; | (since C++20) |
The class contract_violation
describes information about a contract violation. It is generated by a C++ implementation and passed to a contract violation handler when a contract violation is detected.
line_number | returns the line number where the contract violation happened (public member function) |
file_name | returns the name of the file where the contract violation happened (public member function) |
function_name | returns the name of the function where the contract violation happened (public member function) |
comment | returns a string describing the predicate of the violated contract (public member function) |
assertion_level | returns a string describing the assertion level of the violated contract (public member function) |
std::uint_least32_t line_number() const noexcept; |
Returns the location of the source code where the contract violation happened. If the name is unknown, an implementation may return 0 instead.
std::string_view file_name() const noexcept; |
Returns the name of the the source file where the contract violation happened. If the name is unknown, an implementation may return an empty string_view
instead.
std::string_view function_name() const noexcept; |
Returns the name of the function where the contract violation happened. If the name is unknown, an implementation may return an empty string_view
instead.
std::string_view comment() const noexcept; |
Returns an implementation-defined string describing the predicate of the violated contract.
std::string_view assertion_level() const noexcept; |
Returns a string describing the assertion level of the violated contract.
© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
http://en.cppreference.com/w/cpp/error/contract_violation