Boost logo

Boost Users :

Subject: Re: [Boost-users] bind with weak_ptr
From: Igor R (boost.lists_at_[hidden])
Date: 2011-10-10 14:21:05


> I read the article. Sadly, I cannot even begin to follow the code.

What article?
I posted a *ready-to-use* code there, including main() to test it. You
don't have to follow it, just copy&paste it.
(But the code is really short and simple, so if you feel it's unclear
you're welcome to ask.)

> I also tried going back to raw pointers and now I get unhandled exceptions

Of course you'll get segfaults if you access destroyed objects!
What I meant there is that you can use raw pointer *tracking* it with
a separate weak_ptr.
But again, if you think it's too much overhead for your design - just
copy&paste&use the above code.

> So, boost has not built this in yet then, even though there seems to be an
> aweful lot of demand for it?

I believe it's just not too generic. Note that it "does nothing" and
returns a default-constructed result type, when the weak_ptr expires.
It may be appropriate for your specific case, but it's definitely not generic.

HTH,

Igor'.


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