Back to Basics: Lifetime Management in Cpp
Talkat CppCon 2024 · on Thursday, 2024-09-19· at 14:00· Maple 3/4/5, 6700 North Gaylord Rockies Boulevard·
summary
Explains that the concrete claim is: prefer Rule of 0 (use existing value types and managers) and only implement special members when managing resources, which then typically forces the Rule of 5. Demonstrates building a Widget/Gadget that starts with a raw pointer, forces writing copy ctor/assign/dtor, then adds move ctor/assign, uses std::swap and std::exchange and marks moves noexcept, and finally replaces raw memory with unique_ptr — each step compiles and runtime logs show constructors and destructors behaving as expected.
AI-written summary · about
chapters (9)
- 0:00Lifetime management intro
- 4:03Value types in C++
- 8:24Gadget class and default constructors
- 15:16Resource management with raw pointers
- 22:44Rule of three for resources
- 27:24Move semantics and rule of five
- 34:48Rule of zero with managers
- 39:47Type categorization for resources
- 42:58Q&A
related talks
06mLightning Talk: Best Practices Every C++ Programmer Needs to Follow
51mSimplicity: Not Just for Beginners
01h 02mEveryday Efficiency: In-Place Construction (Back to Basics?)
01h 11mPragmatic Simplicity - Actionable Guidelines To Tame Cpp Complexity
01h 00mThe hidden rules of world-class C++ code
01h 01mBack to Basics: Debugging in Cpp
01h 05mBetter Code: Contracts in C++
56mC++ Code Smells
