C++ Contracts – a Meaningfully Viable Product
summary
C++26 accepts a Contracts MVP that adds preconditions postconditions and in-function assertions with a new contract_assert keyword and rules that require contracts on the function first declaration. It specifies constification applies shallowly to external objects, forces const on by-value parameters used in postconditions, disallows repeated contracts with differing predicates or lambdas, and lets implementations pick among four semantics: ignore observe enforce quick_and_force plus configurable repetition and a replaceable handle_contract_violation runtime hook.
AI-written summary · about
chapters (10)
- 0:00Introduction to C++ contracts
- 3:35Contract terminology basics
- 12:50Syntactic restrictions in contracts
- 19:05Constification controversies
- 33:04Post-condition unique features
- 39:57Contract evaluation points
- 42:11Contract semantics modes
- 57:44Side effects in contracts
- 1:03:09Violation handler mechanics
- 1:06:20Contract assert false debate
