Date: 2001-04-05 12:20:07
> I prefer
> void f(auto_ptr<int> & p1, auto_ptr<int> & p2);
> void f(auto_ptr<int> p1, auto_ptr<int> p2);
> 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.
The only possibly confusing aspect of passing auto_ptr by value (when an
exception is thrown) is that the calling function cannot tell if the
ownership was actually given away or not. It may be that it still has
ownership, but it cannot assume that it does.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk