From: Peter Dimov (pdimov_at_[hidden])
Date: 2002-09-21 18:16:13
From: "Howard Hinnant" <hinnant_at_[hidden]>
> But I think I might see a use in:
> T* foo(T* x, /* ... */)
> scoped_ptr<T> p(new ...);
> // big, long, hairy, function
> // ...
> If I knew that scoped_ptr could not transfer resources, no matter what
> (by design of scoped_ptr), then I might immediately have a better
> understanding of how foo worked with respect to p, without having read
> through the whole function. If instead a move_ptr, or other resource
> transferring smart pointer is used, I've got to read through foo to
> discover the true intent of this use. Is it just RAII? Or is p's
> resource transferred out of the function?
Yes, this is the "official" scoped_ptr rationale, but note that foo can
often be rewritten as
T* foo(T* x, /* ... */)
// big, long, hairy, function
and that big, long, hairy functions are problematic either way.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk