2.1 KiB
[basic.contract.handler]
6 Basics [basic]
6.11 Contract assertions [basic.contract]
6.11.3 Contract-violation handler [basic.contract.handler]
The contract-violation handler of 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.