|
Boost : |
From: Rani Sharoni (rani_sharoni_at_[hidden])
Date: 2003-12-11 09:46:59
Peter Dimov wrote:
> Have you read
>
> http://www.boost.org/libs/smart_ptr/sp_techniques.html
Thanks for this awesome usability demonstration!
Maybe it will help me to convince some people in my work place to start
using shared_ptr.
I have few comments regarding failure guaranties. In general I think that
weakening failure guarantee is something that should be avoided and I saw
few places in your paper in which adding shared_ptr changed the failure
guarantee from no-fail into fail with std::bad_alloc since share_ptr
constructor might throw it.
For example:
1) Using shared_ptr as CopyConstructible mutex lock: lock had no fail
guarantee.
2) Using shared_ptr to wrap member function calls: operator-> might have no
fail guarantee. E.g. pointer<X> p; p->cleanup();
3) Delayed deallocation: Y::f() called px.reset that had no fail and
vector::push_back might throw.
One question: why shared_count::shared_count(weak_count const &) throws
boost::bad_weak_ptr and what can be done when catching such exceptions? It
seems to have potential impact on the failure guaranty of many functions
such as impl::getX (Obtaining a shared_ptr to this).
Thanks,
Rani
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk