$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
From: Douglas Gregor (gregod_at_[hidden])
Date: 2002-01-17 15:12:24
On Thursday 17 January 2002 02:02 pm, you wrote:
> In regards to other comments on release(), in an ideal world it would
> not be necessary, but the real world contains other languages besides
> C++, and legacy APIs that are not optional. Providing some control
> over whether release() is exposed will only mean that the class can
> conditionally be made useless.
There appears to be a lot of animosity aimed at release(). Am I correct in
assuming that many here would prefer the removal of release() even from
std::auto_ptr? I've found release() to be quite useful if I need to allocate
several resources at once that won't be assigned to other smart pointers
immediately. For instance, I have several times written the following:
std::auto_ptr<type1> p1 = new type1(...);
std::auto_ptr<type2> p2 = new type2(...);
std::auto_ptr<type3> p3 = new type3(...);
// do lots of frightening exception-throwing stuff
// danger of exceptions is gone, and the allocated pointers have
// safely been stored in other places .
p1.release();
p2.release();
p3.release();
Doug