From 8016988212333266783
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,924f354765fe932a
X-Google-Attributes: gidf78e5,public
X-Google-ArrivalTime: 2002-05-22 13:17:02 PST
Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!bloom-beacon.mit.edu!nycmny1-snh1.gtei.net!news.gtei.net!newsfeed.mathworks.com!kibo.news.demon.net!news.demon.co.uk!demon!mail2news.demon.co.uk!not-for-mail
From: John Nagle <nagle@animats.com>
Newsgroups: comp.std.c++
Subject: Re: constructor calls in vectors
Date: Wed, 22 May 2002 20:16:48 GMT
Organization: Prodigy Internet http://www.prodigy.com
Approved: Fergus Henderson <fjh@cs.mu.oz.au>, moderator of comp.std.c++
Message-ID: <3CEAF4CA.20200@animats.com>
References: <ac1iu6$222i$1@agate.berkeley.edu> <XeeEevAWeV58EwTU@robinton.demon.co.uk> <3CE562E8.8050403@acm.org> <m37km2s6bz.fsf@merlin.nerim.net> <86r8k4e1ec.fsf@alex.gabi-soft.de>
X-Trace: mail2news.demon.co.uk 1022098612 mail2news:9045 mail2news mail2news.demon.co.uk
X-Complaints-To: abuse@demon.net
X-Mail2News-Path: news.demon.net!mulga.cs.mu.oz.au
X-Authentication-Warning: mulga.cs.mu.OZ.AU: fjh set sender to devnull@stump.algebra.com using -f
X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov)
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:0.9.4) Gecko/20011128 Netscape6/6.2.1
X-Accept-Language: en-us
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Date: Tue, 21 May 2002 21:09:03 EDT
X-UserInfo1: O@YORZSDTBSUCFH[OZK@_TDAYZOZ@GXOXZYT]UEK@YUDUWYAKVUOPCW[ML\JXUCKVFDYZKBMSFX^OMSAFNTINTDDMVW[X\THOPXZRVOCJTUTPC\_JSBVX\KAOTBAJBVMZTYAKMNLDI_MFDSSOLXINH__FS^\WQGHGI^C@E[A_CF\AQLDQ\BTMPLDFNVUQ_VM
Lines: 31
Xref: archiver1.google.com comp.std.c++:11422

James Kanze wrote:


> I would argue that this is the correct interpretation.  I'm not 100%
> sure, however, since I don't think that there is any requirement
> concerning the default constructor, and there is a guarantee that it
> is NOT called in constructing the vector.  (It may be called to
> construct the argument to the constructor, of course.)


    I once reported that as a bug in some STL implementation.
New objects were created by invoking the default constructor,
then assigning, rather than by invoking the copy constructor.
It was a bug; only by accident did it work that way.

    This typically comes up when an class contains a data
member which is a reference.  That reference has to be
initialized during construction, and so the default
constructor is usually not meaningful.  Thus, there's
a reason to get this right.

				John Nagle
				Animats


---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]



