Skip to content

Pointer Semantics and Weak Reference Design

Pointers are everywhere in C++, but not all pointers "own" the objects they point to. A raw pointer T* can be either owning or non-owning, T& expresses a borrow but cannot be null, and std::weak_ptr solves the weak reference problem under shared ownership—but what if you don't use std::shared_ptr to manage objects? How is Chromium's base::WeakPtr designed? And why does std::observer_ptr look like a WeakPtr but actually isn't?

In this topic, we build various non-owning pointer types from scratch. As we implement them, we clarify their semantic boundaries, safety conditions, and engineering trade-offs.

Chapter Contents

v0.7.1-2-g3718060 · 3718060 · 2026-07-06