Article View: comp.std.c++
Article #1935Re: Implementing auto_ptr + type of operator->*
From: Dietmar Kuehl
Date: Sat, 09 Sep 1995 16:29
Date: Sat, 09 Sep 1995 16:29
27 lines
1633 bytes
1633 bytes
Hi,
Rogier Goossens (goossens@cs.few.eur.nl) wrote:
: I have two more remarks:
:
: > template<class T>
: > inline void operator=(auto_ptr<T>& rhs)
: > { ptr = rhs.release; }
:
: Don't forget to delete the previous object ptr pointed to.
The standard doesn't say something about deleting the old pointer! My
interpretation is this: auto_ptr is not supposed to delete all pointers
but only the one it is holding when it gets destructed. This semantic
is indeed useful if it is possible that an exception is thrown while
nothing else takes care of the allocated object or some memory should
be released when exiting a function. In the meantime the programmer has
still to care for the pointer if it is replaced.
dk
--
http://www.informatik.uni-konstanz.de/~kuehl
dietmar.kuehl@uni-konstanz.de
I am a realistic optimist - that's why I appear to be slightly pessimistic
---
[ 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. ]
Technical Details
Message-ID:
<42sf4t$9im@eurybia.rz.uni-konstanz.de>Path:
arc1-ca.pugleaf.net!in2.uu.net!bounce-backReferences:
<9509080952.AA15973@jodium.cs.few.eur.nl>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!in2.uu.net!bounce-back Date: 09 Sep 95 16:29:10 GMT Approved: fjh@cs.mu.oz.au From: kuehl@horn.rz.uni-konstanz.de (Dietmar Kuehl) Newsgroups: comp.std.c++ Subject: Re: Implementing auto_ptr + type of operator->* X-Original-Date: 9 Sep 1995 16:25:01 GMT Organization: Fakultdt f|r Mathematik und Informatik Message-ID: <42sf4t$9im@eurybia.rz.uni-konstanz.de> References: <9509080952.AA15973@jodium.cs.few.eur.nl> Reply-To: Dietmar.Kuehl@uni-konstanz.de X-Newsreader: TIN [version 1.1 PL6]