-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Tuesday 17 February 2009, Nat Goodspeed wrote:
As you note above, in addition to the case of my own Trackable base class, I want my visitor to detect a bound boost::shared_ptr<anything> and pass the shared_ptr to my new slot_type object's track() method. In fact, for a boost::shared_ptr<SomeTrackableSubclass>, I want the shared_ptr tracking to take precedence. As you said, this is the safer mechanism.
I can in fact detect a bound shared_ptr and pass it to track() as I want. The problem is that binding a shared_ptr captures a copy, so the referenced object will live until the connection is explicitly disconnected! That makes the slot_type::track() mechanism moot.
It looks as though I could only achieve what I want if my visit_each() visitor could *modify* the boost::bind object to replace the bound shared_ptr with its wrapped plain pointer. I don't believe this is possible?
Wouldn't it be better just to make your visitor just detect a bound shared_ptr to Trackable and report it, forcing the calling code to get it right? You could use BOOST_STATIC_ASSERT to give a compile-time error, for example. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iEYEARECAAYFAkmcE6wACgkQ5vihyNWuA4UmrACffunK2sMbWBY8PBC6XPoC4jpL 74oAnio/0JJRAGBE6V7qCwJBLUbjpfQO =HKR1 -----END PGP SIGNATURE-----