-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Monday 14 September 2009, Monteleone, Nathan wrote:
This is also interesting, although it doesn't help with the tr1 namespace woes: http://boost.org/libs/smart_ptr/sp_techniques.html#weak_without_shared The gist of it is that you can make any object support weak_ptr with an internal shared_ptr to itself, with a null_deleter. Might be of interest for people wanting to track a wider variety of objects.
That's what signals2::trackable does. It's not a thread-safe scheme though, since the contained shared_ptr doesn't really own the object. One thing you could do is bind a weak_ptr as the "this" argument of the member function you are using as a slot, and define a get_pointer() function for your weak_ptr that throws an expired_slot exception when the weak_ptr expires, or returns a shared_ptr otherwise. That would work almost the same as the track(), except the slot could only be removed from the slot list by signal invocations and not during connect() calls. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iEYEARECAAYFAkqullIACgkQ5vihyNWuA4VRgQCfYrvi3me6M9rqr4A5OnivsuNu i8sAoMmOnUOWizwzHsH1qOPMkpJlqnP9 =WFCO -----END PGP SIGNATURE-----