C++ Object Lifetime: From Start to Finish
Talkat CppCon 2023 · on Wednesday, 2023-10-04· at 16:45· Maple 3/4/5, 6700 North Gaylord Rockies Boulevard·
summary
Defines exactly when lifetime starts (storage obtained and constructor completes) and ends (destructor or storage release), demonstrates that temporaries are destroyed at the end of the full expression except for the reference lifetime extension cases, shows how return value optimization usually avoids copies, reproduces a real deadlock caused by a temporary holding a mutex and how the fix removes it, uses CppInsights to inspect generated code, and notes the C++23 range-for fix that made one common pattern safe.
AI-written summary · about
chapters (8)
- 0:00Introduction and basics
- 4:54Object lifetime principles
- 15:21Resource management with RAII
- 18:33References and dangling issues
- 29:42Temporary object lifetimes
- 40:12Lifetime extension exceptions
- 46:24Deadlock case study
- 49:53Q&A session
related talks
01h 00mAn (In-) Complete Guide to C++ Object Lifetimes
35mAn (In-)Complete Guide To C++ Object Lifetimes
58mTaking a Byte Out of C++ - Avoiding Punning by Starting Lifetimes
58mUnderstanding and Mastering C++'s Complexity
53mThe Static Initialization Order Fiasco
01h 02mBack to Basics: C++ Move Semantics
44mThis is why we can('t) have nice things
54mCompile-Time Validation in C++ Programming
