Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2002-09-17 10:49:28


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

> From: "David Abrahams" <dave_at_[hidden]>
> > - The FAQ for scoped_ptr is a little odd: signaling intent and
> transferring
> > ownership are orthogonal. You can use std::auto_ptr<> to signal the
intent
> > to transfer ownership, after all. Maybe it should say: "When reading
> source
> > code, it is valuable to be able to draw conclusions about program
behavior
> > based on the types being used. If scoped_ptr had a release() member, it
> > would become possible to transfer ownership out of its scope, weakening
> its
> > role as a way of limiting resource lifetime to a given scope. Use
> > std::auto_ptr<> where transfer-of-ownership is required"
>
> I'm going to adopt your wording as-is, but I have to admit that I've
never
> bought the "signal intent", "no ownership transfer", "bool vs int"
argument.

Me neither. That's part of why I rewrote it. Maybe we should say:

"If scoped_ptr had a release() member, it would become possible to transfer
ownership of the held pointer, weakening its role as a way of limiting
resource lifetime to a given context"

> If I want to limit an object to a given scope, I can use a simple
variable.
> This is, in part, why I've been reluctant to touch scoped_ptr's
> documentation.
>
> Contrary to the original scoped_ptr intent, I've found it most useful in
> non-scoped scenarios: as a class member, or as a global variable.

I think "as a class member" was considered to be a scoped use - within the
scope of a class instance. I know, it's a little weak, but that's the way I
remember it.

-----------------------------------------------------------
           David Abrahams * Boost Consulting
dave_at_[hidden] * http://www.boost-consulting.com


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk