This article shows how modern C++ features, notably variadic templates and perfect forwarding, can be used to implement a generic variant of observer pattern without the help of either macros or proprietary compiler extensions.
Making Boost.Signals2 More OOP-Friendly
by Pavel Frolov
From the article:
The observer design pattern is by far the most popular and widely known among behavioural patterns. Unfortunately, unlike other mainstream languages out there, the C++ standard library doesn’t provide out of the box observer implementation. Luckily, Boost contains Signals2, a signal/slot library which can serve as a basis for an observer. Using Signals2 as it is, however, is not so convenient in object-oriented program due to the need of manually coded register and notify class methods for each of signal/slot pairs. This article suggests an observable mixin which attempts to solve the outlined problem.
Add a Comment
Comments are closed.