file
contracts.hNamespaces
- namespace rll
- Contract-programming related functions and classes.
- namespace rll::detail
- Contracts implementation details.
Classes
- struct rll::contract_violation
- Contract violation data holder.
Enums
- enum class contract_type: signed char { precondition, postcondition, invariant }
- Type of contract.
Typedefs
-
using contract_violation_handler = std::
function<void(contract_violation const &)> - Contract violation handler type.
Functions
-
void broken_invariant(std::
string_view const message = "Broken invariant", source_location const& location = source_location::current()) - Invokes the global contract violation handler (see violation_
handler) with a broken invariant violation. -
void broken_postcondition(std::
string_view const message = "Broken postcondition", source_location const& location = source_location::current()) - Invokes the global contract violation handler (see violation_
handler) with a broken postcondition violation. -
void broken_precondition(std::
string_view const message = "Broken precondition", source_location const& location = source_location::current()) - Invokes the global contract violation handler (see violation_
handler) with a broken precondition violation. - void default_contract_violation_handler(contract_violation const& violation)
- Default contract violation handler.
-
void invariant(bool const expression,
std::
string_view const message = "Invariant violated", source_location const& location = source_location::current()) - Checks if a given invariant expression is true and throws a contract violation if it is not.
-
auto make_contract_violation(contract_type type,
std::
string_view message, source_location location = source_location::current()) → contract_violation - Creates a contract violation data structure from current location in the source code.
- void not_implemented(source_location const& location = source_location::current())
- Invokes the global contract violation handler (see violation_
handler) with a broken invariant violation. -
void postcondition(bool const expression,
std::
string_view const message = "Postcondition violated", source_location const& location = source_location::current()) - Checks if a given postcondition expression is true and throws a contract violation if it is not.
-
void precondition(bool const expression,
std::
string_view const message = "Precondition violated", source_location const& location = source_location::current()) - Checks if a given precondition expression is true and throws a contract violation if it is not.
- auto set_violation_handler(contract_violation_handler handler) → contract_violation_handler
- Sets the global contract violation handler and returns the old one.
-
void violate(contract_type type,
std::
string_view message, source_location const& location = source_location::current()) - Invokes the global contract violation handler (see violation_
handler) with the violation data from current location in the source code. - auto violation_handler() → contract_violation_handler&
- Returns the current global contract violation handler.
Defines
- #define assert_broken_invariant(...)
- #define assert_broken_precondition(...)
- #define assert_invariant(...)
- #define assert_not_implemented(...)
- #define assert_postcondition(...)
- #define assert_precondition(...)