Home >
Better Code with C++26 Contracts
Design by Contract (DbC) is a software development approach that aims to improve the reliability and maintainability of your code. Under DbC, a function explicitly states what it expects from its caller (preconditions) and what it will guarantee to its caller (postconditions).
C and C++ programmers following DbC have traditionally used assertions as a primitive way to enforce function contracts. C++26 makes DbC much easier by adding function contracts as a full-fledged language feature.
This session explains the intended uses for C++26 contracts and how they improve on traditional assertions. It covers several key areas:
- Capturing information about contract violations at run time, with or without halting the program.
- Clear dos and don’ts for writing effective, high-performance contracts.
- Strategies to prepare your current codebase for contracts if your toolchain doesn’t yet support the C++26 standard.
