From: Dietmar Kuehl (dietmar_kuehl_at_[hidden])
Date: 2000-09-04 10:08:02
"Vugts, Robert" wrote:
> Whilst we are on the subject: Why is the constructor
> that accepts an std::auto_ptr not explicit ?
Maybe because errornous documentation or an errornous implementation
is used? At least the standard I have says that 'std::auto_ptr' has an
ctor taking a pointer (20.5.4 paragraph 2).
> When you're passing around pointers as shared_ptr parameters, it's
> just unnerving always having to provide the explicit ctor-call.
> I couldn't come up with a compelling reason why this should be
> necessary. When there's a function that expects a shared_ptr<Type>,
> why not provide it simply a "new Type()"?
This is actually quite simple: In other contexts it might be rather surprising
when a pointer is suddenly inaccessible just because there was some
appropriate conversion and a shared pointer considered itself responsible
for releasing the object. Since there is no way to determine that a pointer
was just created by 'new' as opposed to originating from a pointer variable,
it is better to play safe - at the cost of having people type some unwanted
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk