From -6019852031690719556
X-Google-Thread: 7894ca11fe,bda36747929f8c7f
X-Google-Attributes: gid7894ca11fe,public,usenet
X-Google-NewGroupId: yes
X-Google-Language: ENGLISH,ASCII-7-bit
Path: g2news2.google.com!news2.google.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date: Sat, 31 Oct 2009 22:10:09 -0500
Return-Path: <cppmods@ruralroute.cs.rpi.edu>
To: (Usenet)
From: Sean Hunt <rideau3@gmail.com>
Newsgroups: comp.std.c++
Subject: Re: How many parameters in T({x, y, z}) ?
Organization: http://groups.google.com
Sender: cppmods@cs.rpi.edu
Approved: stephen.clamage@sun.com
Message-ID: <41c9dc92-4979-4a37-a03c-699c42f6e12e@x6g2000prc.googlegroups.com>
References: <hcghm3$ifu$1@news.albasani.net>
Content-Type: text/plain; charset=ISO-8859-1
X-Original-Date: Sat, 31 Oct 2009 17:36:13 -0700 (PDT)
X-Submission-Address: std-c++@netlab.cs.rpi.edu
Date: Sat, 31 Oct 2009 22:05:59 CST
Lines: 39
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-ZXCy3iByg3UNXqBDVW3LsJYxDYV8Nkt9yNikuOU+MBuvDnyI/z3WWK+S2CvPbng8N4jSQKZYv0XSoEE!98Jo+TT/k6okSTrM1C6Y85tCFArFEHYQQDLDCHNewZnWpz4Q1GQhvki7AF5muNqEtFnj1i74yPTZ!DzEoPk4eNHIZJua0RC9WWOf5QA==
X-Complaints-To: abuse@giganews.com
X-DMCA-Notifications: http://www.giganews.com/info/dmca.html
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40
Xref: g2news2.google.com comp.std.c++:1622

On Oct 31, 12:58 am, Scott Meyers <use...@aristeia.com> wrote:
> Is this a bug in my understanding or a bug in gcc's implementation?
>
> Thanks,
>
> Scott

When you call "Widget w({ 10, 20, 30 })", the compiler sees two
candidates for the constructor - one taking const Widget&, and one
taking three ints. Neither of those is a direct match, but it is
possible to list-initialize a temporary of type Widget using the
triple-int constructor, and then call the copy constructor. This
behavior seems odd for constructors, but it makes sense in the
following scenario:

void foo (int, int, int);
void foo (const Widget&);

int main() {
   foo({10, 20, 30});
}

Would you really expect that call to foo to call the first declaration
of foo?

If you wish to initialize w directly from an initializer-list of three ints, 
you should declare it as "Widget w {10, 20, 30};", which, as I understand it, 
is the initialization syntax that will Do the Right Thing  in nearly every 
scenario.

Sean Hunt


-- 
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@netlab.cs.rpi.edu]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]



