18 Feb 14:57
Re: [signals2][review] The review of the signals2 library (formerly thread_safe_signals) begins today, Nov 1st
Frank Mori Hess <frank.hess <at> nist.gov>
2009-02-18 13:57:00 GMT
2009-02-18 13:57:00 GMT
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.
RSS Feed