[basic.contract.handler] (original) (raw)
6 Basics [basic]
6.10 Contract assertions [basic.contract]
6.10.3 Contract-violation handler [basic.contract.handler]
The contract-violation handlerof a program is a function named::handle_contract_violation.
The contract-violation handler shall have a single parameter of type “lvalue reference to const std::contracts::contract_violation” and shall return void.
The contract-violation handler may have a non-throwing exception specification.
The implementation shall provide a definition of the contract-violation handler, called the default contract-violation handler.
[Note 1:
No declaration for the default contract-violation handler is provided by any standard library header.
— _end note_]
Recommended practice: The default contract-violation handler should produce diagnostic output that suitably formats the most relevant contents of the std::contracts::contract_violation object, rate-limited for potentially repeated violations of observed contract assertions, and then return normally.
It isimplementation-defined whether the contract-violation handler is replaceable ([dcl.fct.def.replace]).
If the contract-violation handler is not replaceable, a declaration of a replacement function for the contract-violation handler is ill-formed, no diagnostic required.