Noexcept? Enabling Testing of Contract Checks in C++
Talkat CppCon 2023 · on Wednesday, 2023-10-04· at 09:00· Cottonwood 8/9, 6700 North Gaylord Rockies Boulevard·
summary
Argument: marking narrow precondition-bearing functions with noexcept breaks the practical workflow of unit-testing contract checks because thrown-test exceptions hit the specifier and call terminate. Demonstration uses assert-style contract checks, an exception-based test harness, and a small Vector implementation (about 10% of vector implemented) to show the failure. Alternatives (longjmp, threads, signals) fail; death tests work but are slow and nonportable. Proposal: a throws nothing annotation that is not observable via the noexcept operator, enabling exception-based testing without terminate.
AI-written summary · about
chapters (10)
- 0:00Welcome
- 1:09Contracts in software
- 4:04noexcept specifier
- 12:13Software contracts types
- 23:39Unit testing contracts
- 33:09Lakos Rule and noexcept
- 48:59Alternatives to exceptions
- 50:25Contract annotation testing
- 55:06Purpose of noexcept
- 1:00:00Conclusion








