Skip to main content

Practice ยท 2 of 2

weak_ptr observer pattern

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.

Difficulty: intermediate

Back to lesson: Practice: unique_ptr practice