Back to Basics: Smart Pointers and RAII
summary
Covers concrete rules: use make_unique/make_shared to avoid allocation+leak races, prefer factory APIs over taking smart pointers, and use enable_shared_from_this to return the same shared ownership instead of recreating managers. Shows that weak_ptr.lock is the thread‑safe way to get a shared handle (checking expired then grabbing it races), demonstrates custom deleters for RAII beyond memory, explains unique_ptr minimal overhead versus shared_ptr reference‑count cost, and points to scope_lock/scope_exit and guideline‑support owner utilities.
AI-written summary · about
chapters (23)
- 0:00Intro
- 0:23Who am I
- 1:01What is ownership
- 1:53Ownership definition
- 7:33Unique ptr
- 10:18Uses
- 14:56Ownership
- 17:13Return
- 21:23Shared Pointers
- 23:29Common Pitfall
- 24:33Weak Pointer
- 26:02Thread Safe
- 28:06Shared Pointers with Library
- 29:49Creating Multiple Shared Pointers
- 31:38Questions
- 32:25Online Question
- 34:09Point Manager
- 35:08RAII
- 35:31Example
- 37:51Standard Library Classes
- 40:01Future Proposals
- 43:11Summary
- 43:50QA
related talks
49mBack to Basics: C++ Smart Pointers
44mBack to Basics: RAII in C++
11mAnatomy of a Smart Pointer
01h 40mBack to the Basics! Essentials of Modern C++ Style
01h 04mException-Safe Code, Part III
01h 01mBack to Basics: C++ API Design
01h 01mException-Safe Code, Part I
01h 02mA Lock-Free Atomic Shared Pointer in Modern Cpp
