Edward Diener wrote:
This is similar to the way in the signals2 library that one has to have
access to a boost::signals2::signal in order to setup a connection to a
slot. So while I like your library I do not immediately understand the
advantage it has over signals2.
When you already have an existing third-party object (say, XButton) it's
more convenient to not have to think where to place the corresponding signal
object. Non-intrusive dispatch is kind of like the library containing the
equivalent of map, automatically managing the signal objects
corresponding to an external, third-party, object.
In the use case in which you define your buttons, there's not much to gain,
you make them contain your signal objects. But third-party buttons don't
contain your signal objects, they contain their own functionality for
notifying you of events, sometimes that's (their own) signal implementation,
sometimes a callback/std::function, sometimes you need to override a virtual
method, sometimes they send you messages. With a non-intrusive signal
library, you just attach an emit call to the third-party notification
mechanism and the rest of the code can connect to the non-intrusive signal.
This avoids the need to wrap the external objects in your own types that
contain signal objects.