C++ Contracts - a meaningful viable product
summary
After two decades of proposals, contracts enter C++26 as the P2900R14 Contracts MVP claiming language-level precondition/postcondition and statement-style contract-assert support. The spec specifies pre/post/contract-assert syntax, implicit constification rules, ODR and lambda caveats, four evaluation semantics (ignore/observe/enforce/quick_enforce), repeatable/elidable checks, a replaceable handle_contract_violation hook, and constraints on postcondition capture; GCC and Clang already host experimental implementations on Godbolt.
AI-written summary · about
chapters (11)
- 0:00C++26 contracts intro
- 1:06Speaker intro
- 3:56Contract types
- 16:31Immutability principles
- 26:54Post-condition capture
- 31:54Parameter constness
- 33:58Contract evaluation
- 45:43Violation handler
- 54:33Assert return value
- 58:51Summary
- 59:33Q&A
related talks
01h 04mC++ Concepts
01h 05mGeneric Programming with Concepts Lite, Part II
58mGeneric Programming with Concepts Lite, Part I
23mHow Type-Driven Development Can Turbocharge your Contract's Security
01h 01mBack to Basics: Concepts in C++
01h 11mC++20 Templates: The next level: Concepts and more
01h 03mTemplates Made Easy with C++20
35mGADTs and You; Writing Safer Code Using GADTs
