From -7733351496912077350 X-Google-Thread: 7894ca11fe,8390690191732735 X-Google-Attributes: gid7894ca11fe,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.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: Mon, 21 Dec 2009 19:10:04 -0600 Return-Path: To: (Usenet) From: "Johannes Schaub (litb)" Newsgroups: comp.std.c++ Subject: Re: Why is std::array an aggregate? Followup-To: comp.std.c++ Organization: T-Online Sender: cppmods@cs.rpi.edu Approved: stephen.clamage@sun.com Message-ID: References: <2fba9f88-3e5e-472f-a2fa-b7b415f07f69@g26g2000yqe.googlegroups.com> Content-Type: text/plain; charset="ISO-8859-1" X-Original-Date: Mon, 21 Dec 2009 19:09:04 +0100 X-Submission-Address: std-c++@netlab.cs.rpi.edu Date: Mon, 21 Dec 2009 19:08:54 CST Lines: 32 X-Usenet-Provider: http://www.giganews.com X-Trace: sv3-m0uc4MVMQe8pt07LVPG0xHRT/v6pKp6n20vH6O8xjz9/CQiBXYrjoXWLGzIFOsXPydI2E1o4UbX+e9I!jC6WoW6mlTcC2es1/T/Z6m6rYA7E7fFUFOxFrLS6gKEnEexfaMcmj74we0Qa 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: g2news1.google.com comp.std.c++:1960 Scott Meyers wrote: > Johannes Schaub (litb) wrote: >> >> I believe this can all be done using variadic templates: >> >> template >> struct array { >> template >> constexpr array(U&&... u):elems{ u... } { } >> >> T elems[S]; >> }; >> >> array a = { 1, 2 }; // works, is statically initialized > > Alas, this won't work, because you can't deduce a template argument's > type from a brace initializer. The standardizion people have decided > that such a type can be deduced in the context of auto, but not a > template. I have no idea why. > This is not deducing a template argument from a brace initializer. It will deduce "U" against "1, 2", not against "{ 1, 2 }" (two arguments 1 and 2 are given to the constructor), if i'm not mistaken. -- [ 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 ]