$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
From: Ronald Garcia (rgarcia4_at_[hidden])
Date: 2001-03-23 11:07:29
BK> Beman wrote:
>> Scoped_ptr is a KISS class - you use it when you want a very
>> simple solution, but use something else (shared_ptr, auto_ptr)
>> if you needs are greater.
BK> I have a class that has member of type scoped_array<> to
BK> handle some memory I allocate... The crux of the situation is
BK> that I'd like to implement a non-throwing swap() for my class
BK> (for other reasons), and to do this, the scoped_array<> would
BK> need a swap(). shared_array is overkill in this situation, but
BK> of course I can roll my own that does what I need... Just
BK> thought this might be a common desire, although I do
BK> understand the drive to keep it as simple as possible.
I had been wondering about the purpose of scoped_ptr for a while,
since it doesn't seem to be made very explicit in the documentation.
short of an offhand comment about the standardization of auto_ptr. Why
would I want to use a scoped_ptr instead of an auto_ptr? I presume it
has something to do with the transfer of ownership semantics of
auto_ptr. In short, I'd like to see an example of a situation where I
would shoot myself in the foot using auto_ptr rather than scoped_ptr
as per my usual policy of looking in the Standard Library before I
look elsewhere. I think that's useful information for the docs.
( on a side note, there's an error in the Handle/Body section of the
scoped_ptr docs, where shared_ptr is mentioned rather than
scoped_ptr).
Given the simplicity of scoped_*, it seems that what you are looking
for is an auto_array, which if I recall correctly has been bounced
around on this mailing list before but has yet to be submitted.
ron