From 9221719832723855771
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!news3.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:20:02 -0600
Return-Path: <cppmods@ruralroute.cs.rpi.edu>
To: (Usenet)
From: Scott Meyers <NeverRead@aristeia.com>
Newsgroups: comp.std.c++
Subject: Re: Why is std::array an aggregate?
Organization: albasani.net
Sender: cppmods@cs.rpi.edu
Approved: stephen.clamage@sun.com
Message-ID: <hgp0l2$vch$1@news.albasani.net>
References: <hgf8r0$7ta$1@news.albasani.net>
  <2fba9f88-3e5e-472f-a2fa-b7b415f07f69@g26g2000yqe.googlegroups.com>
  <hgkrs6$p1f$01$1@news.t-online.com>
  <hgma2a$kaq$1@news.albasani.net>
  <557670f9-71c6-4dc3-832d-dc852f5a7f46@y24g2000yqb.googlegroups.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
X-Original-Date: Mon, 21 Dec 2009 15:33:51 -0800
X-Submission-Address: std-c++@netlab.cs.rpi.edu
Date: Mon, 21 Dec 2009 19:10:30 CST
Lines: 41
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-79IIXGFaP3viW05kRJJDLgmgQB6YXNSZEO3VeZQR2ZgwKp5U5H5G92SH0/cSFyeVUZndw419JQxaDCV!kvfvDkzDUEvyIY7PFTQ2cYsn2drUflb7jUsInDmpUGe1IEf91yhmiO0/
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++:1963

Faisal Vali wrote:
> On Dec 20, 10:00 pm, Scott Meyers <NeverR...@aristeia.com> wrote:
>> Johannes Schaub (litb) wrote:
>>
>>> I believe this can all be done using variadic templates:
>>> template<typename T, size_t S>
>>> struct array {
>>>   template<typename ...U>
>>>   constexpr array(U&&... u):elems{ u... } { }
>>>   T elems[S];
>>> };
>>> array<int, 3> 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.
> 
> 
> I thought we had established here
> http://groups.google.com/group/comp.std.c++/browse_frm/thread/b14c8fad6735a0d9?hl=en#
> that it would work.

Yes, my mistake, I forgot that a templated constructor taking multiple arguments
could be instantiated to match a brace initializer list as long as there is no
constructor taking a std::initializer_list parameter.  Thanks for reminding me
of this.

I thus agree that it appears that making std::array a non-aggregate does not
preclude static initialization.

Which brings me back to my question about whether std::array should be defined
to be one.

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                      ]



