Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2002-08-27 11:18:55

From: "Douglas Gregor" <gregod_at_[hidden]>
> void bar(weak_ptr<X> x)
> {
> some_signal.connect(bind(&X::foo, x));
> }
> We need to get to the X* for the base-pointer conversion to trackable*
> the automatic signal/slot disconnections).

Thinking about it some more.

If we really need the above to be supported, the right approach is:

* mem_fn must recognize weak_ptr and either perform


or call X::foo only when x is nonzero, and silently do nothing otherwise
(but this is only applicable to void functions.)

(I'm undecided whether this coupling is a good thing, and I'm not sure
whether lack of partial ordering on some compilers may prove a problem.)

* The signal must recognize weak_ptr too; a weak_ptr tracks the object
lifetime regardless of whether the object is-a trackable.

For this release, I think that we should leave mem_fn as is; if you decide
to implement a signal that knows about weak_ptr, a temporary workaround
would be to bind a forwarding function

void foo(weak_ptr<X> const & px)

instead of &X::foo.

Boost list run by bdawes at, gregod at, cpdaniel at, john at