|
Boost : |
From: Beman Dawes (bdawes_at_[hidden])
Date: 2002-09-09 13:46:50
At 11:13 AM 9/9/2002, Peter Dimov wrote:
>From: "Thomas Witt" <witt_at_[hidden]>
>
>> ptr != p should be a precondition violation.
>
>I agree (which is why shared_ptr's reset acts the way it does now),
but...
>
>> I can't think of a good reason
>> why a scoped_ptr should be reset with a pointer that is already taken
>care
>of
>> by a scoped ptr.
>
>... the reason for the current behavior is std::auto_ptr compatibility.
>auto_ptr::reset is required to check for self-resets.
>
>> The current code fails if the dtor is called during a call to reset.
Yes,
>> things like this can happen. The managed ptr will be deleted twice.
>
>If you can demonstrate this with an example, you may be able to convince
>Beman and Greg that scoped_ptr doesn't need to check for self-resets. :-)
The original code didn't check for self-reference IIRC. Someone sent in a
use case, but I can't remember what it was, and I can't remember if it
really applied to scoped_ptr.
Personally, I don't think I've ever used scoped_ptr::reset unless ptr==0.
Hum... That brings up a question. If myptr.get()==0, then shouldn't
myptr.reset() be harmless?
--Beman
--Beman
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk