Exception-Safe Code, Part III
summary
Clearly stated, actionable guidelines for C++11/14 exception safety: make_shared/make_unique and smart pointers for ownership, non‑throwing swap (or noexcept moves) plus the swap‑and‑copy idiom, RAII reframed as responsibility acquisition, draw a critical line to get the strong guarantee, and prefer throw‑by‑value/catch‑by‑reference and noexcept destructors. Includes implementation toys: scope guards, exception→error translators (lipandcot), Boost.Exception patterns, and a wrapper/refactor path for legacy code — Adobe‑scale multi‑million‑line migrations succeed with this incremental approach. Materials and code live on the GitHub link.
AI-written summary · about
chapters (25)
- 0:00Start
- 0:25RAII Examples
- 1:35What happens to the object if acquisition fails?
- 3:00Every Resource in a Object
- 4:03Smart Pointer "Gotcha"
- 9:47Lesson Learned
- 13:40Cleanup Code
- 17:30Fundamental Object Functions . Construction
- 22:47Swapperator Examples struct Begin
- 23:39Swapperator Examples template struct Circular Buffer
- 27:53Calling swap in a template (alternative)
- 30:19The Critical Line
- 32:44struct Resource Owner
- 34:12swap()
- 36:59Strategy
- 38:50Most Important Design Guideline
- 41:14Exception-Safety Guidelines
- 42:36Implementation Techniques
- 49:07boost::exception
- 50:16Legacy Code
- 52:11Sean's Rules 1.All new code is written to be exception safe
- 53:37Refactoring Steps
- 54:51Example Code
- 57:04Example Rewrite
- 59:29What does Exception- Safe Code look like?
related talks
49mBack to Basics: C++ Smart Pointers
50mBack to Basics: Smart Pointers and RAII
01h 01mBack to Basics: C++ API Design
59mTo err is human - error handling in C++26
01h 02mBack to Basics: C++ Move Semantics
01h 05mThe real problem of C++
44mBack to Basics: RAII in C++
59mTo err is human - error handling in C++26
