Exception-Safe Code, Part I
summary
Covers concrete rules and examples: the basic/strong/nothrow guarantees, when no‑throw is required (destructors, cleanup, swap/move), and how RAII or move semantics prevent leaks and broken invariants. Shows STL patterns that solve real problems (vector push_back vs insert, stack pop/top), explains why catch by reference and throwable types must be copyable, and gives a compact set of guidelines plus implementation techniques. Slides and source live at https://github.com/CppCon/CppCon2014, C++11/14 focused.
AI-written summary · about
chapters (4)
- 0:00Start
- 12:45Problems with the Return Code Approach • Errors can be ignored • Are ignored by default • If a single call "breaks the chain" by not retuming an error errors cases are lost • Code is tedious to read and write • Exception based coding addresses both of these issues... ... but has issues of its own.
- 29:35First Steps • Carefully check return values/error codes to detect and correct problems • Identify functions that can throw and think about what to do when they fail • Use exception specifications so the compiler can help create sale code. • Use try/catch blocks to control code flow
- 30:54Think structurally • Maintain invariants
related talks
01h 02mBack to Basics: C++ Move Semantics
01h 01mBack to Basics: C++ API Design
49mBack to Basics: C++ Smart Pointers
01h 01mEmbracing PODs Safely Until They Die
50mBack to Basics: Smart Pointers and RAII
01h 03mWriting sustainable software. The how and the what!
01h 04mBack to Basics: Move Semantics
44mBack to Basics: RAII in C++
