Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2002-09-21 10:35:04

From: "Peter Dimov" <pdimov_at_[hidden]>

> From: "David Abrahams" <dave_at_[hidden]>
> > The more I think about scoped_ptr the harder it gets to justify using
> > It still has explicit transfer-of-ownership via reset(), though there's
> > implicit transfer-of-ownership.
> No, reset() cannot be used to transfer ownership away from a scoped_ptr.

No, but swap() can.

> You
> can only transfer ownership into a scoped_ptr, something that you do with
> the constructor as well.

Almost. There's swap().

> > In some sense, std::auto_ptr<T> const is a
> > better candidate for the role that I've always thought scoped_ptr was
> > playing, since there is no reset() member. The case where you need to
> > default construct a smart pointer and later initialize it is enough of
> > corner that I'd be inclined to recommend a straight-up auto_ptr for
> I
> > guess the only downside to auto_ptr for that role is the
> > automatically-generated copy constructor and assignment operator.
> This is scoped_ptr's biggest selling point as far as I'm concerned. :-)

Hmm, still trying to figure out how to teach about this class.

           David Abrahams * Boost Consulting
dave_at_[hidden] *

Boost list run by bdawes at, gregod at, cpdaniel at, john at