Contracts for C++

By Timur Doumler

In this talk, we present contract assertions, a new language feature recently approved for the upcoming C++26 standard after more than two decades of gestation. This feature provides a superior replacement for assertion macros and, when used correctly, can significantly improve the safety and correctness of your code. Contract assertions are designed to have a wide range of applicability with minimal impediments to their adoption in any C++ codebase of any coding style and any quality, so we expect them to become a widely used feature across the ecosystem once C++26 is adopted.

We will cover precondition and postcondition assertions, assertion statements, selection of evaluation semantics, contract-violation handling, and much more, showing use cases and code examples. Then, we will discuss the theoretical underpinnings and design principles behind contract assertions in C++, and compare them with contract facilities in other programming languages such as Eiffel, D, and Ada. Finally, we will present extensions to contract assertions that are being developed for the post-C++26 timeframe and will make the feature even more powerful and able to cover even more use cases.





Your Privacy

By clicking "Accept Non-Essential Cookies" you agree ACCU can store non-essential cookies on your device and disclose information in accordance with our Privacy Policy and Cookie Policy.

Current Setting: Non-Essential Cookies REJECTED


By clicking "Include Third Party Content" you agree ACCU can forward your IP address to third-party sites (such as YouTube) to enhance the information presented on this site, and that third-party sites may store cookies on your device.

Current Setting: Third Party Content EXCLUDED



Settings can be changed at any time from the Cookie Policy page.