From -7731833738000631977 X-Google-Thread: f78e5,51456c3eb8f9490e X-Google-Attributes: gidf78e5,public X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!news1.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed2.easynews.com!easynews.com!easynews!news.alt.net!comp-std-cpp-robomod!not-for-mail From: "kanze" Newsgroups: comp.std.c++ Subject: Re: Copy Constructor Confusion! Date: Mon, 28 Aug 2006 09:09:00 CST Organization: http://groups.google.com Lines: 71 Approved: Fergus Henderson , moderator of comp.std.c++ Message-ID: <1156770985.946413.321730@74g2000cwt.googlegroups.com> References: <1155645873.296811.3890@74g2000cwt.googlegroups.com> <4kebv5Fbjid9U3@individual.net> <1155833275.678725.297060@h48g2000cwc.googlegroups.com> <44e73f70$0$10146$9b4e6d93@newsspool2.arcor-online.net> <1156162332.681008.153540@m73g2000cwd.googlegroups.com> <4l60udFecegU1@individual.net> <1156512377.765813.77030@b28g2000cwb.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1156770991 13089 127.0.0.1 (28 Aug 2006 13:16:31 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 28 Aug 2006 13:16:31 +0000 (UTC) Return-Path: X-Authentication-Warning: mulga.csse.unimelb.edu.au: fjh set sender to devnull@stump.algebra.com using -f X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov) X-Original-To: std-c++@mailman.ucar.edu Delivered-To: std-c++@mailman.ucar.edu User-Agent: G2/0.2 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; SunOS sun4u; en-US; rv:1.0.1) Gecko/20020920 Netscape/7.0,gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: 74g2000cwt.googlegroups.com; posting-host=62.160.54.162; posting-account=qsfl8gwAAABZGaLp2a7FeTfDkJamzWYW X-Virus-Scanned: amavisd-new at ucar.edu X-Virus-Scanned: amavisd-new at csse.unimelb.edu.au X-MIME-Autoconverted: from quoted-printable to 8bit by mulga.csse.unimelb.edu.au id k7SDGnYg007274 X-Virus-Scanned: amavisd-new at csse.unimelb.edu.au Xref: g2news2.google.com comp.std.c++:3554 Frederick Gotham wrote: > kanze posted: > > According to �8.5.1/7: "If there are fewer initializers in the > > list than there are members in the aggregate, then each member > > not explicitly initialized shall be default-initialized." So > > T arr[1] = {} ; > > is the equivalent of: > > T arr[1] = { T() } ; > > which is the equivalent of: > > T arr = T() ; > I don't think you're corrected there. Just because something > is default-initialised, doesn't mean there's a > copy-construction involved. The copy constructor isn't involved because of default initialization. It's involved because "The initialization that occurs in [...] and brace-enclosed initializer lists is called copy-initialization, and is equivalent to the form T x = a;". You're right, however, that default-initialization isn't (normally) copy initialization. Perhaps the intent is that only explicit initializers in the list are copy initialization. If so, I'd say that a DR is in order, because that's not what it says in the above sentence. > For instance: > struct MyClass { > ostringstream obj; > MyClass() : obj() {} > }; That's because "The initialization that occurs in [...] and base and member initializers is called direct-initialization and is equivalent to the form T x(a);." Note that I already quoted the first passage in the post you are responding to. > The following should compile just fine on every > implementation: > #include > using std::ostringstream; > int main() > { > ostringstream arr[1] = {}; > } I still have my doubts. The standard very definitly says that the initialization that occurs in brace-enclosed initializer lists is equivalent to the form T x = a. Which requires an accessible copy constructor. -- James Kanze GABI Software Conseils en informatique orient�e objet/ Beratung in objektorientierter Datenverarbeitung 9 place S�mard, 78210 St.-Cyr-l'�cole, France, +33 (0)1 30 23 00 34 --- [ 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.comeaucomputing.com/csc/faq.html ]