📖 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.

10 chapters▶ runnable code✦ in-depth animation

What this book covers

  1. 01“Implement your own X” — how to play it
  2. 02C-string functions — strlen, strcpy, strcmp
  3. 03A minimal String
  4. 04A minimal vector
  5. 05A minimal unique_ptr
  6. 06A shared_ptr (control block + ref count)
  7. 07A lock-free queue (SPSC ring buffer)
  8. 08A thread-safe blocking queue
  9. 09A spinlock
  10. 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.