From: Matthew Chaplain (boost_fwd_at_[hidden])
Date: 2003-12-18 11:22:45
Rani Sharoni wrote:
> Why is it important that the shared_ptr(weak_ptr<Y> const & r) constructor
> throws an exception?
> I can't avoid thinking that it can easily affect the exception safety of
> code that uses it and this exception indicates about a bug in many cases.
Hi. This is my first attempt (other than a test posting elsewhere) to
Boost via gmane, so I hope it comes out well.
I also came across this problem recently. It was solved by two things:
a) The realisation that the whole purpose of weak_ptr<> is that you
accept that an object may or may not exist the next time you come to
access it. If it still exists, all is well and you may create a
shared_ptr<> from it. If it does not exist, then you are informed and
can handle it gracefully.
b) The discovery of the weak_ptr<>::lock member function.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk