Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2001-04-05 12:38:05


From: <scleary_at_[hidden]>

> > I prefer
> >
> > void f(auto_ptr<int> & p1, auto_ptr<int> & p2);
> >
> > over
> >
> > void f(auto_ptr<int> p1, auto_ptr<int> p2);
> >
> > since
> >
> > f(auto_ptr<int>(new int(1)), auto_ptr<int>(new int(2)));
> >
> > may leak.
>
> I disagree. The objects in question are temporaries passed as function
> arguments, and thus will be cleaned up if an exception is raised.

new int(1)
new int(2) // throws
auto_ptr<int>(new int(1))
auto_ptr<int>(new int(2))

is a valid sequence. See http://www.gotw.ca/gotw/056.htm .

--
Peter Dimov
Multi Media Ltd.

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