Contracts for Dependable C++
summary
Language-level contracts let code state preconditions and postconditions so compilers and static/dynamic analyzers can enforce interfaces rather than rely on comments. The proposal uses an attribute-based syntax (compatible with current C++ attributes) and complements the existing GSL expect macro, gives clear semantics (evaluate args, check precondition, run body, check postcondition), allows runtime abort or throw on violation, permits compile-time proofs to elide checks, and is under implementation for Microsoft’s C++14 updates.
AI-written summary · about
chapters (13)
- 0:00Introduction to contracts
- 3:27Defining contract clauses
- 7:35Preconditions and invariants
- 10:33Practical precondition usage
- 16:38Postconditions explained
- 19:41Breach of contract consequences
- 22:00Goals for C++ contracts
- 24:44Design principles
- 27:05Syntax and examples
- 30:31Contract semantics
- 32:51Validation and enforcement
- 35:09Implementation and scaling
- 40:51Q&A and final discussion
related talks
01h 05m“Contract Programming in C++(20) (part 2 of 2)”
57mPerspectives on Contracts for C++
01h 03m“Contract Programming in C++(20) (part 1 of 2)”
01h 02mContracts in C++26 - An Insider's Overview
01h 32mContracts for C++
58mAvoid Misuse of Contracts!
01h 17mFunction Contracts in Practice using C++
01h 31mWhat C++ Needs to be Safe
