P3290R3 — Integrating Existing Assertions With Contracts
Joshua Berne, Timur Doumler, John Lakos
LEWGSG22
Revisions R6Jul 2026R5Jul 2026R4May 2026R3Jul 2025
WG21 has adopted a contract checking facility as specified in [P2900R14]. C++ now includes three forms of contract assertion: `pre`, `post`, and `contract_assert`. Taken as a unit, these three standard names allow users to express, in a consistent syntax, individual, independent contract checks in their software without changing the meaning (i.e., essential behavior) of that software. Pre-existing contract-checking facilities, such as `assert`, occasionally have fundamentally different semantics and provide completely different control mechanisms for their behavior. Integrating these facilities with the contract-violation handler, however, can be an incredibly useful tool for enabling a gradual migration from older facilities to the newer tools provided by the language itself. With SG21 consensus, this paper proposes both a library API to perform that integration and changes to `assert` to enable its interoperability.