|
Boost : |
From: Vugts, Robert (robert.vugts_at_[hidden])
Date: 2000-09-04 10:28:50
Dietmar,
I was referring to the shared_ptr constructor,
which takes a std::auto_ptr<T> argument.
This constructor is not declared explicit and I was
wondering why.
-- Rob
-----Original Message-----
From: Dietmar Kuehl [mailto:dietmar_kuehl_at_[hidden]]
Sent: 04 September 2000 16:08
To: boost_at_[hidden]
Subject: Re: [boost] Always explicit , why?
Hi,
"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
explicit
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
text, though...
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com
This message is for the named person's use only. It may contain
confidential, proprietary or legally privileged information. No
confidentiality or privilege is waived or lost by any mistransmission.
If you receive this message in error, please immediately delete it and all
copies of it from your system, destroy any hard copies of it and notify the
sender. You must not, directly or indirectly, use, disclose, distribute,
print, or copy any part of this message if you are not the intended
recipient. CREDIT SUISSE GROUP and each of its subsidiaries each reserve
the right to monitor all e-mail communications through its networks. Any
views expressed in this message are those of the individual sender, except
where the message states otherwise and the sender is authorised to state
them to be the views of any such entity.
Unless otherwise stated, any pricing information given in this message is
indicative only, is subject to change and does not constitute an offer to
deal at any price quoted.
Any reference to the terms of executed transactions should be treated as
preliminary only and subject to our formal written confirmation.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk