~/talk

Cpp Contracts - How Contracts in C++26 Can Improve C++ Code Safety and Correctness

Talkat CppCon 2024 · on Sunday, 2024-09-15· [c-and-cpp]
links:none on file
slides:none on file

Proposal p2900 defines a Contracts MVP for C++26 that adds p2900 function preconditions, postconditions and contract-assert statements, a replaceable contract violation handler (default logs and terminates, user supplyable via link‑time replacement), and four evaluation semantics: ignore, observe, enforce and quick_enforce. The committee counts ~196 distinct use cases, virtual function support and constification remain decided-but-tweaky, and GCC/Clang work is underway; the claim is practical, configurable runtime checks that replace macros without changing language guarantees.

AI-written summary · about

  1. 0:00C++ contracts in C++26
  2. 2:57Why contracts took 20 years
  3. 7:16What contracts are
  4. 10:25Contract assertions vs plain language
  5. 13:15P2900 purpose and design
  6. 17:27Code examples and operator[] issues
  7. 22:48Contracts vs assert
  8. 27:20Pre/post condition semantics
  9. 31:09Violation handling and customization
  10. 38:31Three roles in contracts
  11. 42:01Performance trade-offs
  12. 45:55Prime directive and side effects
  13. 48:24Virtual function support
  14. 52:17Open questions and future
  15. 57:32Safety, security, correctness
  16. 1:00:59Q&A
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.