Boost logo

Boost Users :

From: Igor R (boost.lists_at_[hidden])
Date: 2008-07-22 10:19:29


Hello,

When using shared_ptr, we usually take an advantage of weak_ptr to
break the "cycles".
But sometimes the "forth connection" between the objects is by means
of shared_ptr, while the "back connection" is by means of signal-slot
connection. Like this:

shared_ptr<Class1> o1;
shared_ptr<Class2> o2;

o1->someSignal_->connect(bind(&Class2::responder, o2)); // besides, o2
has a shared_ptr to o1

I'd like this signal-slot to be "weak", i.e. instead of
"bind(&Class2::responder, o2)" I wish it could be
"bind(&Class2::responder, weak_ptr(o2))" - which is illegal.
Of course, I can define (and connect to the signal) a wrapping functor
that would store a weak_ptr to the wrapped object, and would try to
lock it in operator(). But probably boost already have some
off-the-shelf solution for this issue?

Thanks!


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