Topic: auto_ptr: : reset and auto_ptr: :operator=
Author: fjh@munta.cs.mu.OZ.AU (Fergus Henderson)
Date: 1995/10/22 Raw View
kuehl@uzwil.rz.uni-konstanz.de (Dietmar Kuehl) writes:
>J. Kanze (kanze@gabi-soft.fr) wrote:
>: Ideally, perhaps, I would want to have assignment and copy construction
>: defined only when the source is a temporary. [...]
>
>The statement with the temporary gave me the following idea: Using two
>classes instead of just one class, it is possible to protect the copy
>constructor and the assignment operator while still allowing a function
>to return a "safe" object.
Yes, you (Dietmar Kuehl), Dag Bruck and I all had much the same idea.
But eddy Gorsuch and James Kanze noticed a much simpler way:
auto_ptr<T> x(foo.release());
y.reset(foo.release());
This seems to me to be quite adequate.
--
Fergus Henderson | "Australia is the richest country in the world,
fjh@cs.mu.oz.au | according to a new system of measuring wealth
http://www.cs.mu.oz.au/~fjh | announced by the World Bank yesterday."
PGP: finger fjh@128.250.37.3 | - Melbourne newspaper "The Age", 18 Sept 1995.
---
[ comp.std.c++ is moderated. Submission address: std-c++@ncar.ucar.edu.
Contact address: std-c++-request@ncar.ucar.edu. The moderation policy
is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]