📖 Book · cpp core · high

⚙️ Smart pointers, from scratch

Reference counting, a from-scratch shared_ptr AND unique_ptr, and the weak_ptr cycle fix.

How shared_ptr, unique_ptr and weak_ptr really work, built from scratch and runnable: the control block and atomic strong count behind a complete SharedPtr<T>, a complete move-only UniquePtr<T> (move/reset/release/get, zero overhead), and the reference-cycle leak that weak_ptr exists to fix.

6 chapters▶ runnable code✦ in-depth animation

What this book covers

  1. 01What a shared_ptr actually is
  2. 02Reference counting in action
  3. 03Build SharedPtr<T> from scratch — run it
  4. 04Build UniquePtr<T> from scratch — move-only, zero overhead
  5. 05The cycle trap — and why weak_ptr fixes it
  6. 06make_shared, deleters & the fine print

Read it in full — runnable C++ + step-through animations

Every chapter of Smart pointers, from scratch ships complete, editable code you compile and run in the browser, plus the same in-depth animations as the lessons.