|
Boost : |
From: Peter Dimov (pdimov_at_[hidden])
Date: 2005-07-15 06:57:22
Russell Hind wrote:
> Just wondered why intrusive_ptr(T * p, bool add_ref = true); isn't
> explicit? The second arg defaults so (using bcc32-5.6.4), an
> intrusive_ptr can be explicitly constructed from a raw ptr. Is this
> intended when shared_ptr is designed to prevent this?
shared_ptr can only be constructed from a raw pointer that has been freshly
obtained via 'new T'. Constructing a shared_ptr from an arbitrary raw
pointer is usually a recipe for disaster.
intrusive_ptr's strength is that it can freely interoperate with raw
pointers, including those that are already managed by another intrusive_ptr.
It is much safer to construct an intrusive_ptr from an arbitrary raw
pointer.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk