📖 Book · cpp core · high
🧰 Implement it yourself: the interview classics
Write your own strlen/String/vector/unique_ptr — then shared_ptr, a lock-free queue, a blocking queue, a spinlock and std::function. All runnable.
The 'write your own X' interview classics, smallest first: strlen/strcpy/strcmp/memcpy, an owning String (Rule of 5 via copy-and-swap), a growable vector with capacity doubling, and a move-only unique_ptr — then the heavier 45-minute favourites: a ref-counted shared_ptr (control block), a lock-free SPSC ring-buffer queue, a thread-safe blocking queue (mutex + condition_variable), a spinlock (atomic_flag), and a minimal std::function (type erasure). Every type compiles and runs in the browser; the goal is to show internal knowledge — pointers, ownership, RAII, atomics & memory order, type erasure — not to reimplement the STL.
What this book covers
- 01“Implement your own X” — how to play it
- 02C-string functions — strlen, strcpy, strcmp
- 03A minimal String
- 04A minimal vector
- 05A minimal unique_ptr
- 06A shared_ptr (control block + ref count)
- 07A lock-free queue (SPSC ring buffer)
- 08A thread-safe blocking queue
- 09A spinlock
- 10A std::function (type erasure)
Read it in full — runnable C++ + step-through animations
Every chapter of Implement it yourself: the interview classics ships complete, editable code you compile and run in the browser, plus the same in-depth animations as the lessons.