Topic: make_array and brace-init list. Should this
Author: Zhihao Yuan <zy@miator.net>
Date: Fri, 19 Aug 2016 11:31:41 -0500
Raw View
On Fri, Aug 19, 2016 at 10:58 AM, S.B.
<i.and.my.little.friends@gmail.com> wrote:
> However, it's possible to add another overload of `to_array` to enable
> `to_array<int>({ {1}, {2}, {3} })`.
Not possible, because initializer_list's size() is a part
of value, which will not affect std::array's size which
is a part of type.
> After all, `to_array<const int>({ {1},
> {2}, {3} })` is already valid (and returns a std::array<int,3>) using
> std::experimental::fundamentals_v2::to_array.
Not valid.
There is a way to support braced-init. First extend
to_array with rvalue reference, then combine this
with compound literals in C:
auto a7 = to_array((std::pair<int, float>[])
{ { 3, .0f }, { 4, .1f }, { 4, .1e23f } });
Implemented,
https://gist.github.com/lichray/6034753#file-make_array-cc-L169
Tested against gcc and clang.
After all it's non-standard.
--
Zhihao Yuan, ID lichray
The best way to predict the future is to invent it.
___________________________________________________
4BSD -- http://blog.miator.net/
--
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.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAGsORuBDGtwc%3DY5P45qdgUG%3DGw09NHDp60eo5UCq0Mi8BpSHbA%40mail.gmail.com.
.
Author: "S.B." <i.and.my.little.friends@gmail.com>
Date: Fri, 19 Aug 2016 09:52:58 -0700 (PDT)
Raw View
------=_Part_3085_517965584.1471625578492
Content-Type: multipart/alternative;
boundary="----=_Part_3086_1494840304.1471625578492"
------=_Part_3086_1494840304.1471625578492
Content-Type: text/plain; charset=UTF-8
http://coliru.stacked-crooked.com/a/ce36e93e14f6983d
On Saturday, August 20, 2016 at 12:31:44 AM UTC+8, Zhihao Yuan wrote:
>
> On Fri, Aug 19, 2016 at 10:58 AM, S.B.
> <i.and.my.li...@gmail.com <javascript:>> wrote:
> > However, it's possible to add another overload of `to_array` to enable
> > `to_array<int>({ {1}, {2}, {3} })`.
>
> Not possible, because initializer_list's size() is a part
> of value, which will not affect std::array's size which
> is a part of type.
>
> > After all, `to_array<const int>({ {1},
> > {2}, {3} })` is already valid (and returns a std::array<int,3>) using
> > std::experimental::fundamentals_v2::to_array.
>
> Not valid.
>
> There is a way to support braced-init. First extend
> to_array with rvalue reference, then combine this
> with compound literals in C:
>
> auto a7 = to_array((std::pair<int, float>[])
> { { 3, .0f }, { 4, .1f }, { 4, .1e23f } });
>
> Implemented,
>
> https://gist.github.com/lichray/6034753#file-make_array-cc-L169
>
> Tested against gcc and clang.
>
> After all it's non-standard.
>
> --
> Zhihao Yuan, ID lichray
> The best way to predict the future is to invent it.
> ___________________________________________________
> 4BSD -- http://blog.miator.net/
>
--
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.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/c9074df6-a0ab-4a44-95c2-3aa7eaf241f6%40isocpp.org.
------=_Part_3086_1494840304.1471625578492
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">http://coliru.stacked-crooked.com/a/ce36e93e14f6983d<br><b=
r>On Saturday, August 20, 2016 at 12:31:44 AM UTC+8, Zhihao Yuan wrote:<blo=
ckquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-=
left: 1px #ccc solid;padding-left: 1ex;">On Fri, Aug 19, 2016 at 10:58 AM, =
S.B.
<br><<a href=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"=
cdpctuc5DAAJ" rel=3D"nofollow" onmousedown=3D"this.href=3D'javascript:&=
#39;;return true;" onclick=3D"this.href=3D'javascript:';return true=
;">i.and.my.li...@<wbr>gmail.com</a>> wrote:
<br>> However, it's possible to add another overload of `to_array` t=
o enable
<br>> `to_array<int>({ {1}, {2}, {3} })`.
<br>
<br>Not possible, because initializer_list's size() is a part
<br>of value, which will not affect std::array's size which
<br>is a part of type.
<br>
<br>> After all, `to_array<const int>({ {1},
<br>> {2}, {3} })` is already valid (and returns a std::array<int,3&g=
t;) using
<br>> std::experimental::<wbr>fundamentals_v2::to_array.
<br>
<br>Not valid.
<br>
<br>There is a way to support braced-init. =C2=A0First extend
<br>to_array with rvalue reference, then combine this
<br>with compound literals in C:
<br>
<br>=C2=A0 auto a7 =3D to_array((std::pair<int, float>[])
<br>=C2=A0 =C2=A0 =C2=A0 { { 3, .0f }, { 4, .1f }, { 4, .1e23f } });
<br>
<br>Implemented,
<br>
<br>=C2=A0 <a href=3D"https://gist.github.com/lichray/6034753#file-make_arr=
ay-cc-L169" target=3D"_blank" rel=3D"nofollow" onmousedown=3D"this.href=3D&=
#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgist.github.com%2Flichray=
%2F6034753%23file-make_array-cc-L169\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQj=
CNF5qFP_5kgbBGJAI1RoiIBRNg1PHg';return true;" onclick=3D"this.href=3D&#=
39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgist.github.com%2Flichray%=
2F6034753%23file-make_array-cc-L169\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjC=
NF5qFP_5kgbBGJAI1RoiIBRNg1PHg';return true;">https://gist.github.com/<w=
br>lichray/6034753#file-make_<wbr>array-cc-L169</a>
<br>
<br>Tested against gcc and clang.
<br>
<br>After all it's non-standard.
<br>
<br>--=20
<br>Zhihao Yuan, ID lichray
<br>The best way to predict the future is to invent it.
<br>______________________________<wbr>_____________________
<br>4BSD -- <a href=3D"http://blog.miator.net/" target=3D"_blank" rel=3D"no=
follow" onmousedown=3D"this.href=3D'http://www.google.com/url?q\x3dhttp=
%3A%2F%2Fblog.miator.net%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHmWTsHV=
Z1D7s1tahvZikRjgaSh7g';return true;" onclick=3D"this.href=3D'http:/=
/www.google.com/url?q\x3dhttp%3A%2F%2Fblog.miator.net%2F\x26sa\x3dD\x26sntz=
\x3d1\x26usg\x3dAFQjCNHmWTsHVZ1D7s1tahvZikRjgaSh7g';return true;">http:=
//blog.miator.net/</a>
<br></blockquote></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/c9074df6-a0ab-4a44-95c2-3aa7eaf241f6%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/c9074df6-a0ab-4a44-95c2-3aa7eaf241f6=
%40isocpp.org</a>.<br />
------=_Part_3086_1494840304.1471625578492--
------=_Part_3085_517965584.1471625578492--
.
Author: "S.B." <i.and.my.little.friends@gmail.com>
Date: Fri, 19 Aug 2016 10:15:44 -0700 (PDT)
Raw View
------=_Part_699_1099054675.1471626944641
Content-Type: multipart/alternative;
boundary="----=_Part_700_779346647.1471626944641"
------=_Part_700_779346647.1471626944641
Content-Type: text/plain; charset=UTF-8
I think it's CWG 1591 (Deducing array bound and element type from
initializer list) <http://wg21.link/cwg1591> that makes this use valid.
On Saturday, August 20, 2016 at 12:31:44 AM UTC+8, Zhihao Yuan wrote:
>
> On Fri, Aug 19, 2016 at 10:58 AM, S.B.
> <i.and.my.li...@gmail.com <javascript:>> wrote:
> > However, it's possible to add another overload of `to_array` to enable
> > `to_array<int>({ {1}, {2}, {3} })`.
>
> Not possible, because initializer_list's size() is a part
> of value, which will not affect std::array's size which
> is a part of type.
>
> > After all, `to_array<const int>({ {1},
> > {2}, {3} })` is already valid (and returns a std::array<int,3>) using
> > std::experimental::fundamentals_v2::to_array.
>
> Not valid.
>
> There is a way to support braced-init. First extend
> to_array with rvalue reference, then combine this
> with compound literals in C:
>
> auto a7 = to_array((std::pair<int, float>[])
> { { 3, .0f }, { 4, .1f }, { 4, .1e23f } });
>
> Implemented,
>
> https://gist.github.com/lichray/6034753#file-make_array-cc-L169
>
> Tested against gcc and clang.
>
> After all it's non-standard.
>
> --
> Zhihao Yuan, ID lichray
> The best way to predict the future is to invent it.
> ___________________________________________________
> 4BSD -- http://blog.miator.net/
>
--
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.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/a39e185d-7b0a-4a45-928b-bbeeefa3b223%40isocpp.org.
------=_Part_700_779346647.1471626944641
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">I think it's <a href=3D"http://wg21.link/cwg1591">CWG =
1591 (Deducing array bound and element type from initializer list)</a> that=
makes this use valid.<br><br>On Saturday, August 20, 2016 at 12:31:44 AM U=
TC+8, Zhihao Yuan wrote:<blockquote class=3D"gmail_quote" style=3D"margin: =
0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">On Fri=
, Aug 19, 2016 at 10:58 AM, S.B.
<br><<a href=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"=
cdpctuc5DAAJ" rel=3D"nofollow" onmousedown=3D"this.href=3D'javascript:&=
#39;;return true;" onclick=3D"this.href=3D'javascript:';return true=
;">i.and.my.li...@<wbr>gmail.com</a>> wrote:
<br>> However, it's possible to add another overload of `to_array` t=
o enable
<br>> `to_array<int>({ {1}, {2}, {3} })`.
<br>
<br>Not possible, because initializer_list's size() is a part
<br>of value, which will not affect std::array's size which
<br>is a part of type.
<br>
<br>> After all, `to_array<const int>({ {1},
<br>> {2}, {3} })` is already valid (and returns a std::array<int,3&g=
t;) using
<br>> std::experimental::<wbr>fundamentals_v2::to_array.
<br>
<br>Not valid.
<br>
<br>There is a way to support braced-init. =C2=A0First extend
<br>to_array with rvalue reference, then combine this
<br>with compound literals in C:
<br>
<br>=C2=A0 auto a7 =3D to_array((std::pair<int, float>[])
<br>=C2=A0 =C2=A0 =C2=A0 { { 3, .0f }, { 4, .1f }, { 4, .1e23f } });
<br>
<br>Implemented,
<br>
<br>=C2=A0 <a href=3D"https://gist.github.com/lichray/6034753#file-make_arr=
ay-cc-L169" target=3D"_blank" rel=3D"nofollow" onmousedown=3D"this.href=3D&=
#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgist.github.com%2Flichray=
%2F6034753%23file-make_array-cc-L169\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQj=
CNF5qFP_5kgbBGJAI1RoiIBRNg1PHg';return true;" onclick=3D"this.href=3D&#=
39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgist.github.com%2Flichray%=
2F6034753%23file-make_array-cc-L169\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjC=
NF5qFP_5kgbBGJAI1RoiIBRNg1PHg';return true;">https://gist.github.com/<w=
br>lichray/6034753#file-make_<wbr>array-cc-L169</a>
<br>
<br>Tested against gcc and clang.
<br>
<br>After all it's non-standard.
<br>
<br>--=20
<br>Zhihao Yuan, ID lichray
<br>The best way to predict the future is to invent it.
<br>______________________________<wbr>_____________________
<br>4BSD -- <a href=3D"http://blog.miator.net/" target=3D"_blank" rel=3D"no=
follow" onmousedown=3D"this.href=3D'http://www.google.com/url?q\x3dhttp=
%3A%2F%2Fblog.miator.net%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHmWTsHV=
Z1D7s1tahvZikRjgaSh7g';return true;" onclick=3D"this.href=3D'http:/=
/www.google.com/url?q\x3dhttp%3A%2F%2Fblog.miator.net%2F\x26sa\x3dD\x26sntz=
\x3d1\x26usg\x3dAFQjCNHmWTsHVZ1D7s1tahvZikRjgaSh7g';return true;">http:=
//blog.miator.net/</a>
<br></blockquote></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/a39e185d-7b0a-4a45-928b-bbeeefa3b223%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/a39e185d-7b0a-4a45-928b-bbeeefa3b223=
%40isocpp.org</a>.<br />
------=_Part_700_779346647.1471626944641--
------=_Part_699_1099054675.1471626944641--
.
Author: Zhihao Yuan <zy@miator.net>
Date: Fri, 19 Aug 2016 13:48:43 -0500
Raw View
On Fri, Aug 19, 2016 at 12:15 PM, S.B.
<i.and.my.little.friends@gmail.com> wrote:
> I think it's CWG 1591 (Deducing array bound and element type from
> initializer list) that makes this use valid.
Interesting. And the rvalue reference overload is really
demanded right now, to enable
to_array<std::unique_ptr<int>>({ std::make_unique<int>(3) })
--
Zhihao Yuan, ID lichray
The best way to predict the future is to invent it.
___________________________________________________
4BSD -- http://blog.miator.net/
--
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.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAGsORuAAdBg7vek7o4v7Gm3VvLBM-vWaC957iUy%2By5tmhAAz4g%40mail.gmail.com.
.