|
Boost Users : |
Subject: Re: [Boost-users] [signals2][review] The review of the signals2 library (formerly thread_safe_signals) begins today, Nov 1st
From: Frank Mori Hess (frank.hess_at_[hidden])
Date: 2009-02-18 08:57:00
-----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-----
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net