Signal library that automatically tracks slot lifetime

I need a C ++ C ++ library with one specific quirk that automatically mutes the signal when an object with a slot is destroyed.

Boost :: signals2 only offers this feature for an object created with boost :: shared_ptr, and I want to keep using std :: shared_ptr everywhere. There is a possibility to make it work with std :: shared_ptr, but it requires writing some specialized templates and there is no information on how this should please and generally I would rather avoid it (unless the code is not available somewhere on the internet, but I couldn't find it).

I know Qt signals have this feature, but Qt is too big to use in every project.

+3


source to share


2 answers


According to the Boost documentation (tested in 1.48.0) the required template specializations for std::shared_ptr

and std::weak_ptr

already exist in Boost, so std

smart pointers should be available out of the box with signals2 (via slot::track_foreign

).



+2


source


I suggest taking a look at the sigslot library - http://sigslot.sourceforge.net



It is a simple mechanism that does not require a preprocessor (such as Qt signals) and provides automatic disabling of remote slots.

+1


source







All Articles