Back to Basics: Exception Handling and Exception Safety
summary
Explains concrete rules: throw objects by value and catch by reference, prefer std::exception subclasses like std::out_of_range, and use RAII to close files during stack unwinding. Shows a file example where G throws a catastrophic_failure and how calling G first and staging results in locals gives the strong guarantee (commit/rollback). Recommends making destructors, operator delete and swap noexcept, demonstrates swap-based commit to implement strong safety, and contrasts table‑based vs dynamic registration exception implementations for performance.
AI-written summary · about
chapters (7)
- 0:00Introduction to exceptions
- 7:20Why exception handling
- 13:04Throwing and catching exceptions
- 23:48Exception safety guarantees
- 30:14RAII and resource management
- 46:07When to use exceptions
- 56:45Exceptions in practice
related talks
01h 03m“What Could Possibly Go Wrong?: A Tale of Expectations and Exceptions”
44mError handling in C++: as easy as "use exceptions"?
01h 29mC++ Error Handling
01h 02mExceptional C++
01h 33mSafe and Sane C++ Types
45mTo Err is Human - Robust Error Handling in C++26
01h 04mKEYNOTE: De-fragmenting C++: Making exceptions more affordable and usable
01h 06mUnwinding the Stack: Exploring How C++ Exceptions Work on Windows
