Contracts, Safety and Correctness in C++
summary
Argues that C++ contracts target safety and correctness: contracts expose pre/post invariants, C++26 defines modes ignore, observe, enforce, quick_enforce and enforce is the default, but contracts can hurt safety if violations terminate programs. Proves safety composes locally (caller must uphold preconditions) while liveness ≠ composable generally, yet proving safety first reduces liveness to progress (no livelocks). Recommends lightweight documentation contracts for concise specs and notes practical limits (heavy runtime checks, virtuals in C++29).
AI-written summary · about
chapters (10)
- 0:00Introduction
- 3:38Correctness, safety, liveness defined
- 14:20Safety flavors and types
- 22:36Safety composability and invariants
- 33:24Liveness does not compose
- 40:20Correctness composability
- 44:57C++ contracts for safety
- 55:02Contracts to correct software
- 1:03:48Key takeaways
- 1:08:52Q&A
related talks
01h 03mCpp Contracts - How Contracts in C++26 Can Improve C++ Code Safety and Correctness
01h 30mContracts, Safety, and the Art of Cat Herding
58mAvoid Misuse of Contracts!
01h 17mFunction Contracts in Practice using C++
01h 21mProgramming with Contracts in C++20
01h 31mContracts for C++
01h 02mContracts in C++26 - An Insider's Overview
01h 32mContracts for C++
