🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #3333

Re: auto_ptr again

#3333
From: J. Kanze
Date: Fri, 09 Feb 1996 15:40
46 lines
3113 bytes
In article <4fbapm$lbk@hermes.synopsys.com> jbuck@Synopsys.COM (Joe
Buck) writes:

> I wrote:
> >|> Anyone who writes a class in which X(X&) or X(const X&) does not have the

> >|> semantics of a copy operation is doing something wrong (e.g. auto_ptr in
> >|> the draft standard is broken).
> 
> James Kanze US/ESC 60/3/141 #40763 <kanze@lts.sel.alcatel.de> writes:
> >I wouldn't go quite that far.  X(X&) is a particular form of copy,
> >which modifies the copied object.  If it is programmed in such a way
> >that the number of intermittent copies is meaningless (as is the case
> >in auto_ptr), then it is perfectly valid.
> 
> You're not really disagreeing with me, James.  X(X&) is a reasonable
> thing to do in some cases, and the source object will then be modified,
> but if this operation does not look like a copy that leaves the
> functioning of the argument object mostly unaltered, the user of the class
> is going to have problems and surprises.  Many uses of X(X&) just modify
> private members to keep some sort of internal record, e.g. how many copies
> there are and connections between them.

That's what mutable is for.

I have no problems with the desired semantics for auto_ptr, for example.
Copy and assignment modify the copied/assigned from object completely.
They render it invalid.  You can hardly say that this is leaving the
object `mostly unaltered'.  However, the number of intermediate objects
is irrelevant; the function is transitive.  The `copy' is actually more
of a `move'.

Perhaps one of the reasons I want auto_ptr so badly in the standard is
that this is *not* something you would want to do in an arbitrary user
class, anymore than you would want to redefine left shift to mean input.
It because valid because it *is* part of the `standard' language;
everyone knows and uses it in this way.
-- 
James Kanze           (+33) 88 14 49 00          email: kanze@gabi-soft.fr
GABI Software, Sarl., 8 rue des Francs Bourgeois, 67000 Strasbourg, France
Conseils, itudes et rialisations en logiciel orienti objet --
              -- A la recherche d'une activiti dans une region francophone
---
[ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  Contact address: std-c++-request@ncar.ucar.edu.  Moderation policy:
  http://reality.sgi.com/employees/austern_mti/std-c++/policy.html. ]
Technical Details
Message-ID: <KANZE.96Feb9155337@gabi.gabi-soft.fr>
Path: arc1-ca.pugleaf.net!in1.uu.net!bounce-back
References: <4ebhn5$lgt@bmtlh10.bnr.ca> <4eucnc$hr9@hermes.synopsys.com> <9602051159.AA19131@lts.sel.alcatel.de> <4fbapm$lbk@hermes.synopsys.com>

Show Full Headers
Complete Article Headers
From: kanze@gabi.gabi-soft.fr (J. Kanze)
Message-ID: <KANZE.96Feb9155337@gabi.gabi-soft.fr>
X-Original-Date: 09 Feb 1996 14:53:37 GMT
Path: arc1-ca.pugleaf.net!in1.uu.net!bounce-back
Date: 09 Feb 96 15:40:02 GMT
Approved: fjh@cs.mu.oz.au
Return-Path: <daemon@meeker.UCAR.EDU>
Newsgroups: comp.std.c++
Subject: Re: auto_ptr again
Organization: GABI Software, Sarl.
References: <4ebhn5$lgt@bmtlh10.bnr.ca> <4eucnc$hr9@hermes.synopsys.com>
 <9602051159.AA19131@lts.sel.alcatel.de> <4fbapm$lbk@hermes.synopsys.com>
In-Reply-To: jbuck@Synopsys.COM's message of 07 Feb 1996 15:00:06 PST
X-Auth: PGPMoose V1.1 PGP comp.std.c++
 iQBFAgUBMRtq3uEDnX0m9pzZAQFnmQF/QoEso0icbPxHXA14EPVMQ2LdeTuRpvYf
 9ParQP7gh/KtBplZliiWVCnNd9aGU3Bh
 =lPSF