Boost logo

Boost Users :

Subject: Re: [Boost-users] bind with weak_ptr
From: Igor R (boost.lists_at_[hidden])
Date: 2011-10-10 11:33:07


> I see many posts when I google this problem. I wonder, since most of them are
> dated 1.35 and previous, if there was ever a solution to this problem?
>
> I think this fellow says it best when he posted,
> "My problem is, that when i bind member functions, if i specify the instance
> of the class as a shared_ptr, then i get memory leaks because the binding's
> shared_ptr to the instance keeps it alive, and it potentially produces cyclic
> references that in the current model, would be complicated to break.
>
> And of course, if i use raw pointers to the binding instances, then i'll get a
> crash if the instance has been destroyed and i try to execute the binding
> function.
>
> So what i would need, is to use bind with weak pointers, and just do nothing
> if locking it fails."
>
> http://www.gamedev.net/topic/494089-help-boostbind-and-shared-pointers/
>
>
> I've almost went to just using raw pointers and letting the program crash if
> the instance to which the member bound no longer exists. I hate to do that.

Have you looked at the link I posted as an answer to one of your
previous questions on the subj?
http://article.gmane.org/gmane.comp.lib.boost.user/70699
Doesn't it do exactly what you want?


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