220 16914 <CAGsORuCBX1agar_iHvieDGfO6HH30gGP3_cp=m1K89+068DYOA@mail.gmail.com> article
Path: news.gmane.org!not-for-mail
From: Zhihao Yuan <zy@miator.net>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Size deduction for std::array from initializer:
 Comments on n3824 std::make_array
Date: Mon, 9 Mar 2015 16:15:13 -0400
Lines: 75
Approved: news@gmane.org
Message-ID: <CAGsORuCBX1agar_iHvieDGfO6HH30gGP3_cp=m1K89+068DYOA@mail.gmail.com>
References: <7a747557-95d6-4484-a7d8-f18fcb05ee59@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
X-Trace: ger.gmane.org 1425932129 5664 80.91.229.3 (9 Mar 2015 20:15:29 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Mon, 9 Mar 2015 20:15:29 +0000 (UTC)
To: "std-proposals@isocpp.org" <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBCSKRWMD4EHBBU7666TQKGQEUNMT6FQ@isocpp.org Mon Mar 09 21:15:18 2015
Return-path: <std-proposals+bncBCSKRWMD4EHBBU7666TQKGQEUNMT6FQ@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-vc0-f197.google.com ([209.85.220.197])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBCSKRWMD4EHBBU7666TQKGQEUNMT6FQ@isocpp.org>)
	id 1YV457-0003UF-4E
	for gclcip-std-proposals@m.gmane.org; Mon, 09 Mar 2015 21:15:17 +0100
Original-Received: by mail-vc0-f197.google.com with SMTP id hy10sf160424497vcb.0
        for <gclcip-std-proposals@m.gmane.org>; Mon, 09 Mar 2015 13:15:16 -0700 (PDT)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:mime-version:in-reply-to:references:date
         :message-id:subject:from:to:content-type:sender:x-original-sender
         :x-original-authentication-results:reply-to:precedence:mailing-list
         :list-id:list-post:list-help:list-archive:list-subscribe
         :list-unsubscribe;
        bh=EV3aE8RV6gIzkUkmQ1obcC5HP6qzOOIyp0ZQ+L123qY=;
        b=E89fTjbN+eg2yvWckkQS4CB86Rjb8JA0XNxehvV+6Zp95OGfGQDNgGow28pxLkdWN9
         0Ru7Uc3L738JVosP8gyJ4lwYM8vvvwVbHMwS1E8Vlv8peGvnuf1sFl48irMtB1+kcog0
         y/QgA9MiN7jFT/edQA2wjTKq3wdGO12dlFWAhD6C9nGYoj7pIOtijGxLi2hnf4H8HzdK
         gsD8ImAnTLOC5N0q511A+Vivnj5yEF+iHdeEGY1WgVmCbGqa5/1S6mr465WPgl18ImCZ
         /hmzWXNBj1FeYfcfL1LY0K12nEG6LmUjXEM8KWQEqeIl6LU5ReSRM14HLDxiWVn+rpcz
         t3vA==
X-Gm-Message-State: ALoCoQnQTvPZOjq8Eg7EmLynqRxcLsMkdjJyp3AjveDx5tkaIZeq1DIvSQniaE4yNNgyP3kR8d1Q
X-Received: by 10.236.223.166 with SMTP id v36mr28048089yhp.45.1425932116122;
        Mon, 09 Mar 2015 13:15:16 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.140.109.119 with SMTP id k110ls1665273qgf.56.gmail; Mon, 09
 Mar 2015 13:15:15 -0700 (PDT)
X-Received: by 10.52.246.170 with SMTP id xx10mr36860516vdc.9.1425932115557;
        Mon, 09 Mar 2015 13:15:15 -0700 (PDT)
Original-Received: from mail-s68.mailgun.info (mail-s68.mailgun.info. [184.173.153.196])
        by mx.google.com with ESMTPS id yh4si10301065vdc.101.2015.03.09.13.15.15
        for <std-proposals@isocpp.org>
        (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Mon, 09 Mar 2015 13:15:15 -0700 (PDT)
Received-SPF: pass (google.com: domain of bounce+3f9131.69110-std-proposals=isocpp.org@miator.net designates 184.173.153.196 as permitted sender) client-ip=184.173.153.196;
Original-Received: from mail-lb0-f174.google.com (mail-lb0-f174.google.com
 [209.85.217.174]) by mxa.mailgun.org with ESMTP id
 54fdff53.7f77fc278b70-in01; Mon, 09 Mar 2015 20:15:15 -0000 (UTC)
Original-Received: by lbiz12 with SMTP id z12so50978808lbi.5 for
 <std-proposals@isocpp.org>; Mon, 09 Mar 2015 13:15:13 -0700 (PDT)
X-Received: by 10.112.170.100 with SMTP id
 al4mr27714078lbc.42.1425932113711; Mon, 09 Mar 2015 13:15:13 -0700 (PDT)
Original-Received: by 10.112.40.114 with HTTP; Mon, 9 Mar 2015 13:15:13 -0700 (PDT)
In-Reply-To: <7a747557-95d6-4484-a7d8-f18fcb05ee59@isocpp.org>
X-Mailgun-Sid: WyI3MTBkYiIsICJzdGQtcHJvcG9zYWxzQGlzb2NwcC5vcmciLCAiNjkxMTAiXQ==
Original-Sender: zy@miator.net
X-Original-Sender: zy@miator.net
X-Original-Authentication-Results: mx.google.com;       spf=pass (google.com:
 domain of bounce+3f9131.69110-std-proposals=isocpp.org@miator.net designates
 184.173.153.196 as permitted sender) smtp.mail=bounce+3f9131.69110-std-proposals=isocpp.org@miator.net;
       dkim=pass header.i=@miator.net
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <std-proposals.isocpp.org>
X-Google-Group-Id: 399137483710
List-Post: <http://groups.google.com/a/isocpp.org/group/std-proposals/post>, <mailto:std-proposals@isocpp.org>
List-Help: <http://support.google.com/a/isocpp.org/bin/topic.py?topic=25838>, <mailto:std-proposals+help@isocpp.org>
List-Archive: <http://groups.google.com/a/isocpp.org/group/std-proposals/>
List-Subscribe: <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:std-proposals+subscribe@isocpp.org>
List-Unsubscribe: <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>,
 <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:16914
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/16914>

On Mon, Mar 9, 2015 at 3:17 PM, Matthew Fioravante
<fmatthew5876@gmail.com> wrote:
> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n3824.htm
>
> It seems that without being able to forward braced initializers this
> solution to "non-type template argument deduction" via a varidic make
> function is incomplete.
>
> struct Point { double x; double y; }
>
> //n3824 forces us to do this:
> auto a = make_array(Point{1.0, 2.0}, Point{3.0, 4.0});
>
> //Should be able to do something like this:
> auto a = make_array<Point>( { 1.0, 2.0 }, { 3.0, 4.0 });
>

The problem of unable to perfect forward braced-init list
is a problem with uniform initialization itself, and applies
to everywhere, not limited to make_array, nor make_*.
If you want to solve it, go solve it.

> Is it really a good
> thing that initializing a C array and initializing a std::array with size
> deduction use different syntax with completely different rules?

Not "completely".  While the language can do something
that library cannot, you will always have caveats, in lots
of places.  But if we choose not to make a progress, we
are probably having bigger issues.

>
> class A {
>   static constexpr auto a = make_array(1, 2, 3);
> };
> constexpr decltype(A::a) A::a; //Ugly, but it works
>
> template <typename T>
> class B {
>   static constexpr auto b = make_array(1, 2, 3);
> };
> template <typename T>
> constexpr decltype(B<T>::b) B<T>::b; //This is a compiler error (it works on
> some versions of gcc, doesn't work on clang, and according to standard
> should fail).
>

Sorry I don't know why this doesn't work.  More like
clang's problem to me.

> and if another proposal enables auto in template parameters, we can do this:
>
> std::array<auto,[]> = { 1, 2, 3}; //is std::array<int,3>
>

Even with that proposal, it still may not work
because { ... } with auto will very likely be deduced
to std::initializer_list<int>, or simply not supported,
but std::array is required to have no (user-declared)
constructor.

-- 
Zhihao Yuan, ID lichray
The best way to predict the future is to invent it.
___________________________________________________
4BSD -- http://bit.ly/blog4bsd

-- 

--- 
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

.
