Contracts for C++
summary
Proposal pushes a Contracts MVP into C++26 with concrete syntax (pre(...), post(...) and contract assert), four runtime modes (ignore, observe, enforce, quick_enforce), and a replaceable handle_contract_violation callback in header <contracts>. Design guarantees zero‑overhead when checks are disabled, allows compile‑time checks, and targets ABI stability, but currently omits virtual‑function and some coroutine cases. Paper is at R6, committee work is ongoing and aims for acceptance before the C++26 evolution deadlines.
AI-written summary · about
chapters (8)
- 0:00C++ contracts intro
- 1:13History and motivation
- 16:08Why C++ needs contracts
- 23:47Standardizing contracts journey
- 36:34Design principles for MVP
- 47:28Contract assertions syntax
- 1:19:23Open design questions
- 1:30:16Summary
related talks
01h 32mContracts for C++
01h 03mCpp Contracts - How Contracts in C++26 Can Improve C++ Code Safety and Correctness
01h 02mContracts in C++26 - An Insider's Overview
01h 30mContracts, Safety, and the Art of Cat Herding
01h 21mProgramming with Contracts in C++20
01h 22mContracts, Safety and Correctness in C++
01h 17mFunction Contracts in Practice using C++
01h 19mEnforce Inform Ignore Assume - Gradual Adoption of Contracts In Production Code
