From 2057817775593001320
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!news.glorb.com!news.alt.net!frodo.cs.rpi.edu!not-for-mail
From: Scott Meyers <usenet@aristeia.com>
Newsgroups: comp.std.c++
Subject: Re: How many parameters in T({x, y, z}) ?
Date: Sun,  1 Nov 2009 21:26:58 CST
Organization: albasani.net
Lines: 37
Sender: cppmods@cs.rpi.edu
Approved: stephen.clamage@sun.com
Message-ID: <hclerr$b6o$1@news.albasani.net>
References: <hcghm3$ifu$1@news.albasani.net>
	<hchqf3$95s$00$1@news.t-online.com>
NNTP-Posting-Host: netlab.cs.rpi.edu
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
To: (Usenet)
Return-Path: <cppmods@ruralroute.cs.rpi.edu>
X-Original-Date: Sun, 01 Nov 2009 18:06:49 -0800
X-Submission-Address: std-c++@netlab.cs.rpi.edu
Xref: g2news2.google.com comp.std.c++:1629

Johannes Schaub (litb) wrote:
> is a braced expression list), and ends up at 13.3.1.3. So in fact the
> argument in your case consists of 1 instead of 3 arguments
[...]
> Now, if you add the initializer list, there are two viable candidate
> functions, instead of only one: The initializer list constructor, and the
> copy constructor. 13.3.3.1.5 maps the conversion sequence for the
> initializer list constructor to an identity conversion by 13.3.3.1.5/2. In
> this case, the copy constructor is still viable, but reference binding is
> going back to 13.3.3.1.5/3 again (because it converts the initializer list
> to "Widget" - *not* to initializer_list<int> which is merely a parameter of
> the constructor used in the user defind conversion sequence.
> 
> Since using the initializer list ctor results in a better conversion
> sequence, it's used over the copy constructor by GCC. I think GCC does it
> all right here.

Given your (very impressive) analysis, I agree.  It will take some time before I
internalize that

   Widget w { a, b, c };

is a constructor call with 1 or 3 arguments (depending on the constructors
offered by Widget), while

   Widget ({a, b, c});

is always a constructor call with 1 argument.

Scott

-- 
[ 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                      ]



