Skip to main content

Practice · 2 of 2

weak_ptr observer pattern

CHALLENGE
Difficulty: intermediate+25 XP

Complete Event: void subscribe(std::weak_ptr<void> w) stores the watcher, and int fire() counts watchers whose object is still alive, pruning expired ones from the list. This is the classic observer pattern that does NOT keep observers alive.

Back to lesson: Practice: unique_ptr practice