The Joy of C++26 Contracts - Myths, Misconceptions & Defensive Programming - Herb Sutter

CppCon CppCon

80,078
1 năm trước
https://cppcon.org
---

The Joy of C++26 Contracts - Myths, Misconceptions & Defensive Programming - Herb Sutter - CppCon 2025
---

This talk is all about the C++26 contracts feature. It covers the following topics:

- Why defensive programming is a Good Thing (mainly for functional safety, but occasionally also for memory safety)
- Brief overview of C++26 contracts, and why they’re way better than C assert (spoiler: writing them on declarations, being able to use them in release builds, and language support is just way better than macros)
- The 3-page “Effective C++ Contracts book” — best practices you need to know to use them (spoiler: keep compound conditions together, don’t write side effects, understand the pros and cons of installing a throwing violation handler… that’s pretty much… it?)
- Why they’re viable, because they address the key things we need in production (which we’ll list)
- Why they’re minimal, because we actually need every part in C++26 to use them at scale (which we’ll do by systematically summarizing why each piece is necessary)
- What the future evolution of contracts holds (spoiler: virtual functions! groups/labels!)
- A review of Frequently Asked Questions

---

Slides: https://github.com/CppCon/CppCon2025/blob/main/Presentations/The_Joy_of_C++26_Contracts_(and_Some_Mythconceptions).pdf

Work at Hudson River Trading (HRT): https://tinyurl.com/safxfctf
---

Herb Sutter

Herb is a technical fellow at Citadel Securities, designer of several Standard C++ features, and chair of the ISO C++ committee and the Standard C++ Foundation. His current interest is simplifying C++.
---

CppCon is the annual, week-long face-to-face gathering for the entire C++ community. The conference is organized by the C++ community for the community. You will enjoy inspirational talks and a friendly atmosphere designed to help attendees learn from each other, meet interesting people, and generally have a stimulating experience. Taking place this year in Aurora, Colorado, near the Denver airport, and including multiple diverse tracks, the conference will appeal to anyone from C++ novices to experts.
Annual CppCon Conference - https://www.cppcon.org
https://www.linkedin.com/company/cppcon
https://x.com/cppcon
https://www.facebook.com/CppConference
https://www.reddit.com/r/cppcon/
https://mastodon.social/@CppCon
---

Videos Filmed & Edited by Bash Films: http://www.BashFilms.com
YouTube Channel Managed by Digital Medium Ltd: https://events.digital-medium.co.uk
---

#cpp #cplusplus #cppcon #cppprogramming #cplusplusprogramming #softwaredevelopment #softwareengineering #coding #code #computerscience #technology #technews #programming #programmer