🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: An STL helper -- and template and type shenanigans

#3243
From: Joe Buck
Date: Mon, 05 Feb 1996 17:22
30 lines
2307 bytes
kanze@lts.sel.alcatel.de (James Kanze US/ESC 60/3/141 #40763) writes:
>In fact, this is a weakness in the STL definition (IMHO).  STL
>containers require *real* copy constructors, that actually copy.  For
>something like auto_ptr, this is not reasonable.

The *language*, not just STL, requires copy constructors that actually
copy.  The language automatically uses the copy constructor whenever it
needs to make a copy.  The copy constructor is used to return objects from
functions and to pass them in by value.  This usaga assumes that you get
an actual copy.  Copy constructors can be optimized away in certain
circumstances.  Again, this optimization works based on the assumption
that a copy constructor does a copy, so you can avoid the copy by
constructing the object in the right place.  It also means that having a
side effect in the copy constructor (other than something that preserves
copy semantics, like reference counting and such) is going to break
things.

Any definition of auto_ptr's copy constructor that doesn't follow these
rules is broken, I'm afraid.  The problem is with auto_ptr, not with
copy constructors or the STL.

-- 
-- Joe Buck 	<jbuck@synopsys.com>	(not speaking for Synopsys, Inc)

Work for something because it is good,
not just because it stands a chance to succeed.	   -- Vaclav Havel
---
[ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy is
  in http://reality.sgi.com/employees/austern_mti/std-c++/policy.html. ]
Technical Details
Message-ID: <4eto87$9kf@hermes.synopsys.com>
Path: arc1-ca.pugleaf.net!fido.asd.sgi.com!austern
References: <01BAEFD6.AD7E8620@dino.int.com> <KANZE.96Feb1141158@slsvewt.lts.sel.alcatel.de>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!fido.asd.sgi.com!austern
From: jbuck@Synopsys.COM (Joe Buck)
Newsgroups: comp.std.c++
Subject: Re: An STL helper -- and template and type shenanigans
Date: 05 Feb 1996 09:22:02 PST
Organization: Synopsys Inc., Mountain View, CA 94043-4033
Approved: austern@isolde.mti.sgi.com
Message-ID: <4eto87$9kf@hermes.synopsys.com>
References: <01BAEFD6.AD7E8620@dino.int.com> <KANZE.96Feb1141158@slsvewt.lts.sel.alcatel.de>
NNTP-Posting-Host: isolde.mti.sgi.com
X-Original-Date: 2 Feb 1996 19:21:43 GMT
X-Auth: PGPMoose V1.1 PGP comp.std.c++
 iQBVAwUBMRY8yEy4NqrwXLNJAQF+WwH/a1U0gqcLHONuuZgQj+sAS292xl0/N+QE
 USxnJYyYGz2kCE2bPfKWGwxBPS2BYvSXYP4rs5EYfEvVGrpYrnscag==
 =R9vs
Originator: austern@isolde.mti.sgi.com