Jason Turner
Jason Turner
Self registration with enable_shared_from_this cannot work https://compiler-explorer.com/z/sPbse6Yxs
Separate registration with shared_ptr https://compiler-explorer.com/z/z51eW653c
Auto registration and deregistration, with inheritance: https://compiler-explorer.com/z/qsjvh5WsT
Generic reusable templated version: https://compiler-explorer.com/z/z5z9e9hEv Do we need to handle the case where the provider can be destroyed before the observer? I don't think this is a normal use case...
A completely decoupled function based approach to observer: https://compiler-explorer.com/z/WGvo5rebE
Self managing decoupled observer: https://compiler-explorer.com/z/dM8hnKs4z
Slightly cleaned up version of the above: https://compiler-explorer.com/z/588cMveTc
0 overhead Compile time registration of observers: https://compiler-explorer.com/z/7xqjs99sY
Observations for Observer Pattern: * It's close to signal/slots from Qt * The classic examples assume a reference counted language * The classic examples casually ignore the possibility of cyclic...
> Check this, instead of an “Observer” I created an “Observed”, I thinks you will like some of the stuff. > > https://compiler-explorer.com/z/bGoEPT76x To say that "Lefticus hates std::function because...