220 10426 <2be92780-bf68-4634-a193-7461f71de3f7@isocpp.org> article
Path: news.gmane.org!not-for-mail
From: douglas.boffey@gmail.com
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Generated initializer_list
Date: Tue, 29 Apr 2014 02:53:34 -0700 (PDT)
Lines: 141
Approved: news@gmane.org
Message-ID: <2be92780-bf68-4634-a193-7461f71de3f7@isocpp.org>
References: <357dd72f-c749-4dc5-aa6d-5ac4528aba5a@isocpp.org>
 <CAB+4KHKqB1NC=HYjrZSm=Brj7-Vh50ovTJjnJYpq-Css+mUssw@mail.gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; 
	boundary="----=_Part_638_15144896.1398765214779"
X-Trace: ger.gmane.org 1398765225 26225 80.91.229.3 (29 Apr 2014 09:53:45 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Tue, 29 Apr 2014 09:53:45 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBDSIZVXVVUFBBH7N7WNAKGQECHXFE4A@isocpp.org Tue Apr 29 11:53:39 2014
Return-path: <std-proposals+bncBDSIZVXVVUFBBH7N7WNAKGQECHXFE4A@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-qc0-f198.google.com ([209.85.216.198])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBDSIZVXVVUFBBH7N7WNAKGQECHXFE4A@isocpp.org>)
	id 1Wf4jL-0005uU-2N
	for gclcip-std-proposals@m.gmane.org; Tue, 29 Apr 2014 11:53:39 +0200
Original-Received: by mail-qc0-f198.google.com with SMTP id r5sf28433956qcx.9
        for <gclcip-std-proposals@m.gmane.org>; Tue, 29 Apr 2014 02:53:36 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20120113;
        h=date:from:to:message-id:in-reply-to:references:subject:mime-version
         :x-original-sender:reply-to:precedence:mailing-list:list-id
         :list-post:list-help:list-archive:list-subscribe:list-unsubscribe
         :content-type;
        bh=PzcB6Mdxr3pN5/FlAoBLR30IIP82hkIExp/Z32kvago=;
        b=ve1raWAtTlPOSqvZ9AxleN0zKDfLNEQXzrMaI7lI/gaYt+MFfH7y/GTh6kMrS1+C/U
         tl/0YjJ7ojcacJ2WjFbVcZ+L9IACuhli24Kq/ufFTQCwjT5CLur8vOMxLmlkxzixAyUc
         ciQ3Ejzg64U49L8ir4hBBsHHXqQZ1ckCq3vGLt+eYcjy8sLYSJbNYb4FiEXFXZ+hFB/Y
         GXEZAjAxN9kRGh7K9DmYtwNtlA1gyTRtpZfVn38OTSWfOFbozu0rq9wuLcUcgi9OteSo
         AARbvwxPgB9m8CBwzqGLdpYnQi3U96RdHr10GJILAag4kxXHhsPUIvTpZUYJ8CqkXk4M
         Enew==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:date:from:to:message-id:in-reply-to:references
         :subject:mime-version:x-original-sender:reply-to:precedence
         :mailing-list:list-id:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe:content-type;
        bh=PzcB6Mdxr3pN5/FlAoBLR30IIP82hkIExp/Z32kvago=;
        b=BOI+kLKcBuSeYSHV0n0LjGhT8CbtFwtqCexti1tVRpC/N1OyjUIie9yM9Fivv5fHki
         73C7tfWFerxozXBA3ZwlLunbWL3iy34OWm3mS2GuvZOiDZAkTs0uZSZqllZxysrB+/s2
         1Z341DjirtHyFNehhUF0xpPRXOl/HOGq5i5EGt3qTdSRaJxgOwWNor3LxK+/USkqw7/T
         29VyiYz7E/hBX//yARFHP8gwzRiN0M+qvfTt6CHRSIZ8kHt6tAauOaHBcpCQ8dyKHRpI
         pMZkvrSbQ3JqMhph2v81tsClmyGrWSINXUcZzGWeHHVr3TK0fvV+VSL1NlCdPM4MrXQQ
         zHPQ==
X-Gm-Message-State: ALoCoQnCyO6fxIYAUFTug+CZ1sNb/v1ex+hB5Ox3x4ZY9IkH+BsgC6PJ+wn1Wfs/GSre8KI81ovZ
X-Received: by 10.236.231.52 with SMTP id k50mr13912579yhq.52.1398765216267;
        Tue, 29 Apr 2014 02:53:36 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.140.80.145 with SMTP id c17ls27535qgd.60.gmail; Tue, 29 Apr
 2014 02:53:35 -0700 (PDT)
X-Received: by 10.140.104.168 with SMTP id a37mr17786qgf.20.1398765215541;
        Tue, 29 Apr 2014 02:53:35 -0700 (PDT)
In-Reply-To: <CAB+4KHKqB1NC=HYjrZSm=Brj7-Vh50ovTJjnJYpq-Css+mUssw@mail.gmail.com>
X-Original-Sender: douglasboffey@gmail.com
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: <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:10426
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/10426>

------=_Part_638_15144896.1398765214779
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable


>
> To represent a compile-time sequence of values of a given literal type=20
>> T you can use an array defined with constexpr:=20
>>
>>     constexpr T a[] =3D ...;=20
>>
> The problem with that is that the array is a list of literals=20
(or constexprs).  There should be a method to generate the list from an=20
algorithm, and have the generated list stored in the object file.  As far=
=20
as I can tell, that facility is not available, either in core, nor in the=
=20
library.
I would like to type something along the lines of:
=20
constexpr auto primes[5] =3D get_nth_prime;
=20
given a function
=20
constexpr unsigned int get_nth_prime(size_t n)
=20
which would be equivalent to
=20
constexpr unsigned int primes[] =3D {2, 3, 5, 7, 11};
=20

> If the values differ in type you can use a class type of literal type:=20
>>
>>     constexpr struct=20
>>     {=20
>>          T1 v1;=20
>>          T2 v2;=20
>>          T3 v3;=20
>>     } S =3D ...;=20
>>
>> There are a few other options, but it isn't clear from your example=20
>> what the problem is with the above.  In all cases you can write a=20
>> constexpr function that returns the above types (well, you need to=20
>> wrap the array in a struct to return it as usual).  You can create a=20
>> mutable local variable of the type within the constexpr function, fill=
=20
>> it out, and return it:=20
>>
>> There are some limitations on literal types that different people are=20
>> thinking about and working on, but it isn't clear which one (if any)=20
>> you are hitting upon.=20
>
>
> This again misses the point=E2=80=94I=E2=80=99m not talking about aggrega=
tes of different=20
types.  I am sorry if my example was not clear.

> =20

--=20

---=20
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 e=
mail 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-proposa=
ls/.

------=_Part_638_15144896.1398765214779
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><BLOCKQUOTE style=3D"BORDER-LEFT: #ccc 1px solid; MARGIN: =
0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class=3Dgmail_quote>
<BLOCKQUOTE style=3D"BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex=
; PADDING-LEFT: 1ex" class=3Dgmail_quote>To represent a compile-time sequen=
ce of values of a given literal type <BR>T you can use an array defined wit=
h constexpr: <BR><BR>&nbsp; &nbsp; constexpr T a[] =3D ...; <BR></BLOCKQUOT=
E></BLOCKQUOTE>
<DIV>The problem with that is that the array is a list of literals (or&nbsp=
;constexprs).&nbsp; There should be a method to generate the list from an a=
lgorithm, and have the generated list stored in the object file.&nbsp; As f=
ar as I can tell, that facility is not available, either in core, nor in th=
e library.<BR></DIV>
<DIV>I would like to type something along the lines of:</DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT color=3D#9900ff>constexpr auto primes[5] =3D get_nth_prime;</FON=
T></DIV>
<DIV>&nbsp;</DIV>
<DIV>given a function</DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT color=3D#9900ff>constexpr unsigned int&nbsp;get_nth_prime(size_t=
 n)</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV>which would be equivalent to</DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT color=3D#9900ff>constexpr&nbsp;unsigned int&nbsp;primes[] =3D {2=
, 3, 5, 7, 11};</FONT></DIV>
<DIV>&nbsp;</DIV>
<BLOCKQUOTE style=3D"BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex=
; PADDING-LEFT: 1ex" class=3Dgmail_quote>
<BLOCKQUOTE style=3D"BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex=
; PADDING-LEFT: 1ex" class=3Dgmail_quote>If the values differ in type you c=
an use a class type of literal type: <BR><BR>&nbsp; &nbsp; constexpr struct=
 <BR>&nbsp; &nbsp; { <BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;T1 v1; <BR>&nbsp=
; &nbsp; &nbsp; &nbsp; &nbsp;T2 v2; <BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;T=
3 v3; <BR>&nbsp; &nbsp; } S =3D ...; <BR><BR>There are a few other options,=
 but it isn't clear from your example <BR>what the problem is with the abov=
e. &nbsp;In all cases you can write a <BR>constexpr function that returns t=
he above types (well, you need to <BR>wrap the array in a struct to return =
it as usual). &nbsp;You can create a <BR>mutable local variable of the type=
 within the constexpr function, fill <BR>it out, and return it: <BR><BR>The=
re are some limitations on literal types that different people are <BR>thin=
king about and working on, but it isn't clear which one (if any) <BR>you ar=
e hitting upon. </BLOCKQUOTE><BR></BLOCKQUOTE>
<DIV>This again misses the point=E2=80=94I=E2=80=99m not talking about aggr=
egates of different types.&nbsp; I am sorry if my example was not clear.</D=
IV>
<BLOCKQUOTE style=3D"BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex=
; PADDING-LEFT: 1ex" class=3Dgmail_quote>&nbsp;</BLOCKQUOTE></div>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

------=_Part_638_15144896.1398765214779--

.
