Topic: std::type_pack_element


Author: Andrey Davydov <andrey.a.davydov@gmail.com>
Date: Thu, 11 Oct 2018 12:05:37 -0700 (PDT)
Raw View
------=_Part_433_324133861.1539284737261
Content-Type: multipart/alternative;
 boundary="----=_Part_434_939583920.1539284737261"

------=_Part_434_939583920.1539284737261
Content-Type: text/plain; charset="UTF-8"

It's often needed to index into template parameter pack, when working with
variadic templates, for instance in implementation of std::get<size_t> of
tuple and variant. I wonder if there is any proposal to add metafunction
<std::size_t I, typename ...Ts>
using type_pack_element = ...
It can be implemented using existing language facilities or, similarly to
std::make_integer_sequence, using compiler intrinsic. It's already
implemented in Clang (__type_pack_element), and IMO it should not be hard
to support in other compilers. Moreover it should be much more efficient
from compile-time perspective because variadic pack is stored in some
vector-like data structure, and consequently to get element by index from
it is much cheaper than class template instantiation, overload resolution,
etc...

--
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/f2d44cc1-d626-4adb-9f4c-b4555ee4cb08%40isocpp.org.

------=_Part_434_939583920.1539284737261
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><span style=3D"font-size: small;">It&#39;s often needed to=
 index into template parameter pack, when working with variadic templates, =
for instance in implementation of <font face=3D"courier new, monospace">std=
::get&lt;size_t&gt;</font> of <font face=3D"courier new, monospace">tuple</=
font> and <font face=3D"courier new, monospace">variant</font>. I wonder if=
 there is any proposal to add metafunction=C2=A0</span><div class=3D"pretty=
print" style=3D"background-color: rgb(250, 250, 250); border-color: rgb(187=
, 187, 187); border-style: solid; border-width: 1px; overflow-wrap: break-w=
ord;"><code class=3D"prettyprint"><div class=3D"subprettyprint"><span style=
=3D"color: #008;" class=3D"styled-by-prettify">&lt;std::size_t</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"=
color: #606;" class=3D"styled-by-prettify">I</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify">, </span><span style=3D"color: #606;" cla=
ss=3D"styled-by-prettify">typename</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> ...</span><span style=3D"color: #606;" class=3D"st=
yled-by-prettify">Ts</span><span style=3D"color: #008;" class=3D"styled-by-=
prettify">&gt;</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"><br>using type_pack_element =3D ...<br></span></div></code></div><div><=
span style=3D"font-size: small;">It</span><span style=3D"font-size: small;"=
>=C2=A0</span><span style=3D"font-size: small;">can be implemented using ex=
isting language facilities or, similarly to <font face=3D"courier new, mono=
space">std::make_integer_sequence</font>, using compiler intrinsic. It&#39;=
s already implemented in Clang (<font face=3D"courier new, monospace">__typ=
e_pack_element</font>), and IMO it should not be hard to support in other c=
ompilers. Moreover it should be much more efficient from compile-time persp=
ective because variadic pack is stored in some vector-like data structure, =
and consequently to get element by index from it is much cheaper than class=
 template instantiation, overload resolution, etc...</span></div></div>

<p></p>

-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/f2d44cc1-d626-4adb-9f4c-b4555ee4cb08%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/f2d44cc1-d626-4adb-9f4c-b4555ee4cb08=
%40isocpp.org</a>.<br />

------=_Part_434_939583920.1539284737261--

------=_Part_433_324133861.1539284737261--

.


Author: Tony V E <tvaneerd@gmail.com>
Date: Thu, 11 Oct 2018 15:30:12 -0400
Raw View
<html><head></head><body lang=3D"en-US" style=3D"background-color: rgb(255,=
 255, 255); line-height: initial;">                                        =
                                              <div style=3D"width: 100%; fo=
nt-size: initial; font-family: Calibri, 'Slate Pro', sans-serif, sans-serif=
; color: rgb(31, 73, 125); text-align: initial; background-color: rgb(255, =
255, 255);">Can you show an example of use?</div>                          =
                                                                           =
                                <div style=3D"width: 100%; font-size: initi=
al; font-family: Calibri, 'Slate Pro', sans-serif, sans-serif; color: rgb(3=
1, 73, 125); text-align: initial; background-color: rgb(255, 255, 255);"><b=
r style=3D"display:initial"></div>                                         =
                                                                           =
                                                                           =
    <div style=3D"font-size: initial; font-family: Calibri, 'Slate Pro', sa=
ns-serif, sans-serif; color: rgb(31, 73, 125); text-align: initial; backgro=
und-color: rgb(255, 255, 255);">Sent&nbsp;from&nbsp;my&nbsp;BlackBerry&nbsp=
;portable&nbsp;Babbage&nbsp;Device</div>                                   =
                                                                           =
                                                                    <table =
width=3D"100%" style=3D"background-color:white;border-spacing:0px;"> <tbody=
><tr><td colspan=3D"2" style=3D"font-size: initial; text-align: initial; ba=
ckground-color: rgb(255, 255, 255);">                           <div style=
=3D"border-style: solid none none; border-top-color: rgb(181, 196, 223); bo=
rder-top-width: 1pt; padding: 3pt 0in 0in; font-family: Tahoma, 'BB Alpha S=
ans', 'Slate Pro'; font-size: 10pt;">  <div><b>From: </b>Andrey Davydov</di=
v><div><b>Sent: </b>Thursday, October 11, 2018 3:05 PM</div><div><b>To: </b=
>ISO C++ Standard - Future Proposals</div><div><b>Reply To: </b>std-proposa=
ls@isocpp.org</div><div><b>Subject: </b>[std-proposals] std::type_pack_elem=
ent</div></div></td></tr></tbody></table><div style=3D"border-style: solid =
none none; border-top-color: rgb(186, 188, 209); border-top-width: 1pt; fon=
t-size: initial; text-align: initial; background-color: rgb(255, 255, 255);=
"></div><br><div id=3D"_originalContent" style=3D""><div dir=3D"ltr"><span =
style=3D"font-size: small;">It's often needed to index into template parame=
ter pack, when working with variadic templates, for instance in implementat=
ion of <font face=3D"courier new, monospace">std::get&lt;size_t&gt;</font> =
of <font face=3D"courier new, monospace">tuple</font> and <font face=3D"cou=
rier new, monospace">variant</font>. I wonder if there is any proposal to a=
dd metafunction&nbsp;</span><div class=3D"prettyprint" style=3D"background-=
color: rgb(250, 250, 250); border-color: rgb(187, 187, 187); border-style: =
solid; border-width: 1px; overflow-wrap: break-word;"><code class=3D"pretty=
print"><div class=3D"subprettyprint"><span style=3D"color: #008;" class=3D"=
styled-by-prettify">&lt;std::size_t</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"> </span><span style=3D"color: #606;" class=3D"styl=
ed-by-prettify">I</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify">, </span><span style=3D"color: #606;" class=3D"styled-by-prettify">t=
ypename</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> ..=
..</span><span style=3D"color: #606;" class=3D"styled-by-prettify">Ts</span>=
<span style=3D"color: #008;" class=3D"styled-by-prettify">&gt;</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"><br>using type_pack_ele=
ment =3D ...<br></span></div></code></div><div><span style=3D"font-size: sm=
all;">It</span><span style=3D"font-size: small;">&nbsp;</span><span style=
=3D"font-size: small;">can be implemented using existing language facilitie=
s or, similarly to <font face=3D"courier new, monospace">std::make_integer_=
sequence</font>, using compiler intrinsic. It's already implemented in Clan=
g (<font face=3D"courier new, monospace">__type_pack_element</font>), and I=
MO it should not be hard to support in other compilers. Moreover it should =
be much more efficient from compile-time perspective because variadic pack =
is stored in some vector-like data structure, and consequently to get eleme=
nt by index from it is much cheaper than class template instantiation, over=
load resolution, etc...</span></div></div>

<p></p>

-- <br>
You received this message because you are subscribed to the Google Groups "=
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/f2d44cc1-d626-4adb-9f4c-b4555ee4cb08%=
40isocpp.org?utm_medium=3Demail&amp;utm_source=3Dfooter">https://groups.goo=
gle.com/a/isocpp.org/d/msgid/std-proposals/f2d44cc1-d626-4adb-9f4c-b4555ee4=
cb08%40isocpp.org</a>.<br>
<br><!--end of _originalContent --></div></body></html>

<p></p>

-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/20181011193012.5218385.29683.63037%40=
gmail.com?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.com=
/a/isocpp.org/d/msgid/std-proposals/20181011193012.5218385.29683.63037%40gm=
ail.com</a>.<br />

.


Author: Barry Revzin <barry.revzin@gmail.com>
Date: Thu, 11 Oct 2018 12:32:40 -0700 (PDT)
Raw View
------=_Part_382_1415981283.1539286360488
Content-Type: multipart/alternative;
 boundary="----=_Part_383_536282594.1539286360488"

------=_Part_383_536282594.1539286360488
Content-Type: text/plain; charset="UTF-8"



On Thursday, October 11, 2018 at 2:05:37 PM UTC-5, Andrey Davydov wrote:
>
> It's often needed to index into template parameter pack, when working with
> variadic templates, for instance in implementation of std::get<size_t> of
> tuple and variant. I wonder if there is any proposal to add metafunction
> <std::size_t I, typename ...Ts>
> using type_pack_element = ...
> It can be implemented using existing language facilities or, similarly to
> std::make_integer_sequence, using compiler intrinsic. It's already
> implemented in Clang (__type_pack_element), and IMO it should not be hard
> to support in other compilers. Moreover it should be much more efficient
> from compile-time perspective because variadic pack is stored in some
> vector-like data structure, and consequently to get element by index from
> it is much cheaper than class template instantiation, overload resolution,
> etc...
>

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0949r0.html

What you're looking for is called mp_at_c in the proposal, except it takes
a "list" as the first parameter instead of a trailing template parameter.
So yours implemented in terms of that one would just be:

template <size_t I, typename... Ts>
using type_pack_element = mp_at_c<mp_list<Ts...>, I>;

This is already in Boost as the Mp11 library, if you want to just use it.

--
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/3790787d-92b8-46db-bcda-bd965b2178d3%40isocpp.org.

------=_Part_383_536282594.1539286360488
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><br>On Thursday, October 11, 2018 at 2:05:37 PM UTC-5,=
 Andrey Davydov wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;=
margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=
=3D"ltr"><span style=3D"font-size:small">It&#39;s often needed to index int=
o template parameter pack, when working with variadic templates, for instan=
ce in implementation of <font face=3D"courier new, monospace">std::get&lt;s=
ize_t&gt;</font> of <font face=3D"courier new, monospace">tuple</font> and =
<font face=3D"courier new, monospace">variant</font>. I wonder if there is =
any proposal to add metafunction=C2=A0</span><div style=3D"background-color=
:rgb(250,250,250);border-color:rgb(187,187,187);border-style:solid;border-w=
idth:1px"><code><div><span style=3D"color:#008">&lt;std::size_t</span><span=
 style=3D"color:#000"> </span><span style=3D"color:#606">I</span><span styl=
e=3D"color:#000">, </span><span style=3D"color:#606">typename</span><span s=
tyle=3D"color:#000"> ...</span><span style=3D"color:#606">Ts</span><span st=
yle=3D"color:#008">&gt;</span><span style=3D"color:#000"><br>using type_pac=
k_element =3D ...<br></span></div></code></div><div><span style=3D"font-siz=
e:small">It</span><span style=3D"font-size:small">=C2=A0</span><span style=
=3D"font-size:small">can be implemented using existing language facilities =
or, similarly to <font face=3D"courier new, monospace">std::make_integer_se=
quence</font>, using compiler intrinsic. It&#39;s already implemented in Cl=
ang (<font face=3D"courier new, monospace">__type_pack_element</font>), and=
 IMO it should not be hard to support in other compilers. Moreover it shoul=
d be much more efficient from compile-time perspective because variadic pac=
k is stored in some vector-like data structure, and consequently to get ele=
ment by index from it is much cheaper than class template instantiation, ov=
erload resolution, etc...</span></div></div></blockquote><div><br></div><di=
v>http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0949r0.html</div=
><div><br></div><div>What you&#39;re looking for is called mp_at_c in the p=
roposal, except it takes a &quot;list&quot; as the first parameter instead =
of a trailing template parameter. So yours implemented in terms of that one=
 would just be:</div><div><br></div><div><div class=3D"prettyprint" style=
=3D"background-color: rgb(250, 250, 250); border-color: rgb(187, 187, 187);=
 border-style: solid; border-width: 1px; overflow-wrap: break-word;"><code =
class=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D"color: #=
008;" class=3D"styled-by-prettify">template</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">&lt;</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify">size_t I</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">,</span><font color=3D"#000000"><span style=3D"color: #000;=
" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">typename</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">...</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> </span><span style=3D"color: #606;" class=3D"styled-by-pr=
ettify">Ts</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
&gt;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></=
span><span style=3D"color: #008;" class=3D"styled-by-prettify">using</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"> type_pack_elemen=
t </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> mp_at_c</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify">mp_list</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span><span style=3D"=
color: #606;" class=3D"styled-by-prettify">Ts</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">...&gt;,</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"> I</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">&gt;;</span></font><font color=3D"#000000"></font>=
</div></code></div><br>This is already in Boost as the Mp11 library, if you=
 want to just use it.=C2=A0</div></div>

<p></p>

-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/3790787d-92b8-46db-bcda-bd965b2178d3%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/3790787d-92b8-46db-bcda-bd965b2178d3=
%40isocpp.org</a>.<br />

------=_Part_383_536282594.1539286360488--

------=_Part_382_1415981283.1539286360488--

.


Author: =?UTF-8?Q?Jonathan_M=C3=BCller?= <jonathanmueller.dev@gmail.com>
Date: Thu, 11 Oct 2018 21:36:09 +0200
Raw View
--000000000000d317e60577f91502
Content-Type: text/plain; charset="UTF-8"

On Thu, Oct 11, 2018, 21:30 Tony V E <tvaneerd@gmail.com> wrote:

> Can you show an example of use?
>
> Sent from my BlackBerry portable Babbage Device
> *From: *Andrey Davydov
> *Sent: *Thursday, October 11, 2018 3:05 PM
> *To: *ISO C++ Standard - Future Proposals
> *Reply To: *std-proposals@isocpp.org
> *Subject: *[std-proposals] std::type_pack_element
>
> It's often needed to index into template parameter pack, when working with
> variadic templates, for instance in implementation of std::get<size_t> of
> tuple and variant. I wonder if there is any proposal to add metafunction
> <std::size_t I, typename ...Ts>
> using type_pack_element = ...
> It can be implemented using existing language facilities or, similarly to
> std::make_integer_sequence, using compiler intrinsic. It's already
> implemented in Clang (__type_pack_element), and IMO it should not be hard
> to support in other compilers. Moreover it should be much more efficient
> from compile-time perspective because variadic pack is stored in some
> vector-like data structure, and consequently to get element by index from
> it is much cheaper than class template instantiation, overload resolution,
> etc...
>

template <size_t I, typename ... Ts>
struct tuple_element<I, tuple<Ts...>>
{
     using type = type_pack_element<I, Ts...>;
};

>

--
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/CAEddoJanwC6M%2B-uA00_wwOjkojTGX5CA%2BgjOb%3DGLfcGjrysPKQ%40mail.gmail.com.

--000000000000d317e60577f91502
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"auto"><div class=3D"gmail_quote"><div dir=3D"ltr">On Thu, Oct 1=
1, 2018, 21:30 Tony V E &lt;<a href=3D"mailto:tvaneerd@gmail.com" target=3D=
"_blank">tvaneerd@gmail.com</a>&gt; wrote:<br></div><blockquote class=3D"gm=
ail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-le=
ft:1ex"><div lang=3D"en-US" style=3D"background-color:rgb(255,255,255);line=
-height:initial">                                                          =
                            <div style=3D"width:100%;font-size:initial;font=
-family:Calibri,&#39;Slate Pro&#39;,sans-serif,sans-serif;color:rgb(31,73,1=
25);text-align:initial;background-color:rgb(255,255,255)">Can you show an e=
xample of use?</div>                                                       =
                                                                           =
   <div style=3D"width:100%;font-size:initial;font-family:Calibri,&#39;Slat=
e Pro&#39;,sans-serif,sans-serif;color:rgb(31,73,125);text-align:initial;ba=
ckground-color:rgb(255,255,255)"><br style=3D"display:initial"></div>      =
                                                                           =
                                                                           =
                                       <div style=3D"font-size:initial;font=
-family:Calibri,&#39;Slate Pro&#39;,sans-serif,sans-serif;color:rgb(31,73,1=
25);text-align:initial;background-color:rgb(255,255,255)">Sent=C2=A0from=C2=
=A0my=C2=A0BlackBerry=C2=A0portable=C2=A0Babbage=C2=A0Device</div>         =
                                                                           =
                                                                           =
                   <table width=3D"100%" style=3D"background-color:white;bo=
rder-spacing:0px"> <tbody><tr><td colspan=3D"2" style=3D"font-size:initial;=
text-align:initial;background-color:rgb(255,255,255)">                     =
      <div style=3D"border-style:solid none none;border-top-color:rgb(181,1=
96,223);border-top-width:1pt;padding:3pt 0in 0in;font-family:Tahoma,&#39;BB=
 Alpha Sans&#39;,&#39;Slate Pro&#39;;font-size:10pt">  <div><b>From: </b>An=
drey Davydov</div><div><b>Sent: </b>Thursday, October 11, 2018 3:05 PM</div=
><div><b>To: </b>ISO C++ Standard - Future Proposals</div><div><b>Reply To:=
 </b><a href=3D"mailto:std-proposals@isocpp.org" rel=3D"noreferrer" target=
=3D"_blank">std-proposals@isocpp.org</a></div><div><b>Subject: </b>[std-pro=
posals] std::type_pack_element</div></div></td></tr></tbody></table><div st=
yle=3D"border-style:solid none none;border-top-color:rgb(186,188,209);borde=
r-top-width:1pt;font-size:initial;text-align:initial;background-color:rgb(2=
55,255,255)"></div><br><div id=3D"m_6276406016202303097m_-42445419426147649=
22_originalContent"><div dir=3D"ltr"><span style=3D"font-size:small">It&#39=
;s often needed to index into template parameter pack, when working with va=
riadic templates, for instance in implementation of <font face=3D"courier n=
ew, monospace">std::get&lt;size_t&gt;</font> of <font face=3D"courier new, =
monospace">tuple</font> and <font face=3D"courier new, monospace">variant</=
font>. I wonder if there is any proposal to add metafunction=C2=A0</span><d=
iv class=3D"m_6276406016202303097m_-4244541942614764922prettyprint" style=
=3D"background-color:rgb(250,250,250);border-color:rgb(187,187,187);border-=
style:solid;border-width:1px"><code class=3D"m_6276406016202303097m_-424454=
1942614764922prettyprint"><div class=3D"m_6276406016202303097m_-42445419426=
14764922subprettyprint"><span style=3D"color:#008" class=3D"m_6276406016202=
303097m_-4244541942614764922styled-by-prettify">&lt;std::size_t</span><span=
 style=3D"color:#000" class=3D"m_6276406016202303097m_-4244541942614764922s=
tyled-by-prettify"> </span><span style=3D"color:#606" class=3D"m_6276406016=
202303097m_-4244541942614764922styled-by-prettify">I</span><span style=3D"c=
olor:#000" class=3D"m_6276406016202303097m_-4244541942614764922styled-by-pr=
ettify">, </span><span style=3D"color:#606" class=3D"m_6276406016202303097m=
_-4244541942614764922styled-by-prettify">typename</span><span style=3D"colo=
r:#000" class=3D"m_6276406016202303097m_-4244541942614764922styled-by-prett=
ify"> ...</span><span style=3D"color:#606" class=3D"m_6276406016202303097m_=
-4244541942614764922styled-by-prettify">Ts</span><span style=3D"color:#008"=
 class=3D"m_6276406016202303097m_-4244541942614764922styled-by-prettify">&g=
t;</span><span style=3D"color:#000" class=3D"m_6276406016202303097m_-424454=
1942614764922styled-by-prettify"><br>using type_pack_element =3D ...<br></s=
pan></div></code></div><div><span style=3D"font-size:small">It</span><span =
style=3D"font-size:small">=C2=A0</span><span style=3D"font-size:small">can =
be implemented using existing language facilities or, similarly to <font fa=
ce=3D"courier new, monospace">std::make_integer_sequence</font>, using comp=
iler intrinsic. It&#39;s already implemented in Clang (<font face=3D"courie=
r new, monospace">__type_pack_element</font>), and IMO it should not be har=
d to support in other compilers. Moreover it should be much more efficient =
from compile-time perspective because variadic pack is stored in some vecto=
r-like data structure, and consequently to get element by index from it is =
much cheaper than class template instantiation, overload resolution, etc...=
</span></div></div></div></div></blockquote><div dir=3D"auto"><br></div><di=
v dir=3D"auto">template &lt;size_t I, typename ... Ts&gt;</div><div dir=3D"=
auto">struct tuple_element&lt;I, tuple&lt;Ts...&gt;&gt;</div><div dir=3D"au=
to">{</div><div dir=3D"auto">=C2=A0 =C2=A0 =C2=A0using type =3D type_pack_e=
lement&lt;I, Ts...&gt;;</div><div dir=3D"auto">};</div><blockquote class=3D=
"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding=
-left:1ex"><div lang=3D"en-US" style=3D"background-color:rgb(255,255,255);l=
ine-height:initial"><div id=3D"m_6276406016202303097m_-4244541942614764922_=
originalContent"><div dir=3D"ltr"><div><span style=3D"font-size:small"></sp=
an></div></div></div></div>
</blockquote></div></div>

<p></p>

-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CAEddoJanwC6M%2B-uA00_wwOjkojTGX5CA%2=
BgjOb%3DGLfcGjrysPKQ%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfoote=
r">https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAEddoJanwC=
6M%2B-uA00_wwOjkojTGX5CA%2BgjOb%3DGLfcGjrysPKQ%40mail.gmail.com</a>.<br />

--000000000000d317e60577f91502--

.


Author: Andrey Davydov <andrey.a.davydov@gmail.com>
Date: Thu, 11 Oct 2018 12:52:22 -0700 (PDT)
Raw View
------=_Part_440_969420258.1539287542912
Content-Type: multipart/alternative;
 boundary="----=_Part_441_941435819.1539287542913"

------=_Part_441_941435819.1539287542913
Content-Type: text/plain; charset="UTF-8"


>
> Can you show an example of use?
>
> Sent from my BlackBerry portable Babbage Device
> *From: *Andrey Davydov
> *Sent: *Thursday, October 11, 2018 3:05 PM
> *To: *ISO C++ Standard - Future Proposals
> *Reply To: *std-pr...@isocpp.org <javascript:>
> *Subject: *[std-proposals] std::type_pack_element
>
> It's often needed to index into template parameter pack, when working with
> variadic templates, for instance in implementation of std::get<size_t> of
> tuple and variant. I wonder if there is any proposal to add metafunction
> <std::size_t I, typename ...Ts>
> using type_pack_element = ...
> It can be implemented using existing language facilities or, similarly to
> std::make_integer_sequence, using compiler intrinsic. It's already
> implemented in Clang (__type_pack_element), and IMO it should not be hard
> to support in other compilers. Moreover it should be much more efficient
> from compile-time perspective because variadic pack is stored in some
> vector-like data structure, and consequently to get element by index from
> it is much cheaper than class template instantiation, overload resolution,
> etc...
>
> --
> 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-proposal...@isocpp.org <javascript:>.
> To post to this group, send email to std-pr...@isocpp.org <javascript:>.
> To view this discussion on the web visit
> https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/f2d44cc1-d626-4adb-9f4c-b4555ee4cb08%40isocpp.org
> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/f2d44cc1-d626-4adb-9f4c-b4555ee4cb08%40isocpp.org?utm_medium=email&utm_source=footer>
> .
>

template<typename... Ts, size_t... J>
class tuple_impl<index_sequence<J...>, Ts...> : element_storage<Ts, J>...
{
  template<size_t I> friend decltype(auto) get(tuple & t)
  {
    using element_type = type_pack_element<I, Ts...>;
    return static_cast<element_storage<element_type, I> &>(t).get();
  }
};

--
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/0d33adb8-2de9-4d10-9218-cdc45e950115%40isocpp.org.

------=_Part_441_941435819.1539287542913
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;bor=
der-left: 1px #ccc solid;padding-left: 1ex;"><div lang=3D"en-US" style=3D"b=
ackground-color:rgb(255,255,255);line-height:initial"><div style=3D"width:1=
00%;font-size:initial;font-family:Calibri,&#39;Slate Pro&#39;,sans-serif,sa=
ns-serif;color:rgb(31,73,125);text-align:initial;background-color:rgb(255,2=
55,255)">Can you show an example of use?</div>                             =
                                                                           =
                             <div style=3D"width:100%;font-size:initial;fon=
t-family:Calibri,&#39;Slate Pro&#39;,sans-serif,sans-serif;color:rgb(31,73,=
125);text-align:initial;background-color:rgb(255,255,255)"><br style=3D"dis=
play:initial"></div>                                                       =
                                                                           =
                                                                 <div style=
=3D"font-size:initial;font-family:Calibri,&#39;Slate Pro&#39;,sans-serif,sa=
ns-serif;color:rgb(31,73,125);text-align:initial;background-color:rgb(255,2=
55,255)">Sent=C2=A0from=C2=A0my=C2=A0BlackBerry=C2=A0<wbr>portable=C2=A0Bab=
bage=C2=A0Device</div>                                                     =
                                                                           =
                                                  <table width=3D"100%" sty=
le=3D"background-color:white;border-spacing:0px"> <tbody><tr><td colspan=3D=
"2" style=3D"font-size:initial;text-align:initial;background-color:rgb(255,=
255,255)">                           <div style=3D"border-style:solid none =
none;border-top-color:rgb(181,196,223);border-top-width:1pt;padding:3pt 0in=
 0in;font-family:Tahoma,&#39;BB Alpha Sans&#39;,&#39;Slate Pro&#39;;font-si=
ze:10pt">  <div><b>From: </b>Andrey Davydov</div><div><b>Sent: </b>Thursday=
, October 11, 2018 3:05 PM</div><div><b>To: </b>ISO C++ Standard - Future P=
roposals</div><div><b>Reply To: </b><a href=3D"javascript:" target=3D"_blan=
k" gdf-obfuscated-mailto=3D"821KZs4wAwAJ" rel=3D"nofollow" onmousedown=3D"t=
his.href=3D&#39;javascript:&#39;;return true;" onclick=3D"this.href=3D&#39;=
javascript:&#39;;return true;">std-pr...@isocpp.org</a></div><div><b>Subjec=
t: </b>[std-proposals] std::type_pack_element</div></div></td></tr></tbody>=
</table><div style=3D"border-style:solid none none;border-top-color:rgb(186=
,188,209);border-top-width:1pt;font-size:initial;text-align:initial;backgro=
und-color:rgb(255,255,255)"></div><br><div><div dir=3D"ltr"><span style=3D"=
font-size:small">It&#39;s often needed to index into template parameter pac=
k, when working with variadic templates, for instance in implementation of =
<font face=3D"courier new, monospace">std::get&lt;size_t&gt;</font> of <fon=
t face=3D"courier new, monospace">tuple</font> and <font face=3D"courier ne=
w, monospace">variant</font>. I wonder if there is any proposal to add meta=
function=C2=A0</span><div style=3D"background-color:rgb(250,250,250);border=
-color:rgb(187,187,187);border-style:solid;border-width:1px"><code><div><sp=
an style=3D"color:#008">&lt;std::size_t</span><span style=3D"color:#000"> <=
/span><span style=3D"color:#606">I</span><span style=3D"color:#000">, </spa=
n><span style=3D"color:#606">typename</span><span style=3D"color:#000"> ...=
</span><span style=3D"color:#606">Ts</span><span style=3D"color:#008">&gt;<=
/span><span style=3D"color:#000"><br>using type_pack_element =3D ...<br></s=
pan></div></code></div><div><span style=3D"font-size:small">It</span><span =
style=3D"font-size:small">=C2=A0</span><span style=3D"font-size:small">can =
be implemented using existing language facilities or, similarly to <font fa=
ce=3D"courier new, monospace">std::make_integer_sequence</font>, using comp=
iler intrinsic. It&#39;s already implemented in Clang (<font face=3D"courie=
r new, monospace">__type_pack_element</font>), and IMO it should not be har=
d to support in other compilers. Moreover it should be much more efficient =
from compile-time perspective because variadic pack is stored in some vecto=
r-like data structure, and consequently to get element by index from it is =
much cheaper than class template instantiation, overload resolution, etc...=
</span></div></div>

<p></p>

-- <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"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"=
821KZs4wAwAJ" rel=3D"nofollow" onmousedown=3D"this.href=3D&#39;javascript:&=
#39;;return true;" onclick=3D"this.href=3D&#39;javascript:&#39;;return true=
;">std-proposal...@<wbr>isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"javascript:" target=3D"_bla=
nk" gdf-obfuscated-mailto=3D"821KZs4wAwAJ" rel=3D"nofollow" onmousedown=3D"=
this.href=3D&#39;javascript:&#39;;return true;" onclick=3D"this.href=3D&#39=
;javascript:&#39;;return true;">std-pr...@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/f2d44cc1-d626-4adb-9f4c-b4555ee4cb08%=
40isocpp.org?utm_medium=3Demail&amp;utm_source=3Dfooter" target=3D"_blank" =
rel=3D"nofollow" onmousedown=3D"this.href=3D&#39;https://groups.google.com/=
a/isocpp.org/d/msgid/std-proposals/f2d44cc1-d626-4adb-9f4c-b4555ee4cb08%40i=
socpp.org?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" on=
click=3D"this.href=3D&#39;https://groups.google.com/a/isocpp.org/d/msgid/st=
d-proposals/f2d44cc1-d626-4adb-9f4c-b4555ee4cb08%40isocpp.org?utm_medium\x3=
demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com=
/a/<wbr>isocpp.org/d/msgid/std-<wbr>proposals/f2d44cc1-d626-4adb-<wbr>9f4c-=
b4555ee4cb08%40isocpp.org</a><wbr>.<br></div></div></blockquote><div>=C2=A0=
</div><div class=3D"prettyprint" style=3D"background-color: rgb(250, 250, 2=
50); border-color: rgb(187, 187, 187); border-style: solid; border-width: 1=
px; overflow-wrap: break-word;"><code class=3D"prettyprint"><div class=3D"s=
ubprettyprint"><span style=3D"color: #008;" class=3D"styled-by-prettify">te=
mplate</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;=
</span><span style=3D"color: #008;" class=3D"styled-by-prettify">typename</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">...</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #606;" class=3D"styled-by-prettify">Ts</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;"=
 class=3D"styled-by-prettify"> size_t</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">...</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"> J</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">&gt;</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"><br></span><span style=3D"color: #008;" class=3D"styled-by-prettify">=
class</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> tupl=
e_impl</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify">index_sequ=
ence</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify">J</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">...&gt;,</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"=
color: #606;" class=3D"styled-by-prettify">Ts</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">...&gt;</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">:</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> element_storage</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">&lt;</span><span style=3D"color: #606;" class=3D"style=
d-by-prettify">Ts</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> J=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&gt;...</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 </span><span styl=
e=3D"color: #008;" class=3D"styled-by-prettify">template</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify">size_t I</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">&gt;</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">friend</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by=
-prettify">decltype</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">(</span><span style=3D"color: #008;" class=3D"styled-by-prettify">=
auto</span><span style=3D"color: #660;" class=3D"styled-by-prettify">)</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span s=
tyle=3D"color: #008;" class=3D"styled-by-prettify">get</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify">tuple </span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">&amp;</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> t</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">)</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"><br>=C2=A0 </span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">{</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
><br>=C2=A0 =C2=A0 </span><span style=3D"color: #008;" class=3D"styled-by-p=
rettify">using</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> element_type </span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
> type_pack_element</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">&lt;</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y">I</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span s=
tyle=3D"color: #606;" class=3D"styled-by-prettify">Ts</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">...&gt;;</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> <br>=C2=A0 =C2=A0 </span><span st=
yle=3D"color: #008;" class=3D"styled-by-prettify">return</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #008;" class=3D"styled-by-prettify">static_cast</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">&lt;</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify">element_storage</span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">&lt;</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify">element</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify">_type</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> I</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">&gt;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">&amp;&gt=
;(</span><span style=3D"color: #000;" class=3D"styled-by-prettify">t</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">).</span><span st=
yle=3D"color: #008;" class=3D"styled-by-prettify">get</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">();</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify"><br>=C2=A0 </span><span style=3D"color:=
 #660;" class=3D"styled-by-prettify">}</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"> <br></span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">};</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> </span></div></code></div><div><br></div>

<p></p>

-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/0d33adb8-2de9-4d10-9218-cdc45e950115%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/0d33adb8-2de9-4d10-9218-cdc45e950115=
%40isocpp.org</a>.<br />

------=_Part_441_941435819.1539287542913--

------=_Part_440_969420258.1539287542912--

.


Author: Andrey Davydov <andrey.a.davydov@gmail.com>
Date: Thu, 11 Oct 2018 13:01:34 -0700 (PDT)
Raw View
------=_Part_481_677548995.1539288094341
Content-Type: multipart/alternative;
 boundary="----=_Part_482_47684529.1539288094341"

------=_Part_482_47684529.1539288094341
Content-Type: text/plain; charset="UTF-8"


>
> On Thursday, October 11, 2018 at 2:05:37 PM UTC-5, Andrey Davydov wrote:
>>
>> It's often needed to index into template parameter pack, when working
>> with variadic templates, for instance in implementation of
>> std::get<size_t> of tuple and variant. I wonder if there is any proposal
>> to add metafunction
>> <std::size_t I, typename ...Ts>
>> using type_pack_element = ...
>> It can be implemented using existing language facilities or, similarly
>> to std::make_integer_sequence, using compiler intrinsic. It's already
>> implemented in Clang (__type_pack_element), and IMO it should not be
>> hard to support in other compilers. Moreover it should be much more
>> efficient from compile-time perspective because variadic pack is stored in
>> some vector-like data structure, and consequently to get element by index
>> from it is much cheaper than class template instantiation, overload
>> resolution, etc...
>>
>
> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0949r0.html
>
Thank you for the link to this proposal.

>
> What you're looking for is called mp_at_c in the proposal, except it takes
> a "list" as the first parameter instead of a trailing template parameter.
> So yours implemented in terms of that one would just be:
>
> template <size_t I, typename... Ts>
> using type_pack_element = mp_at_c<mp_list<Ts...>, I>;
>
> This is already in Boost as the Mp11 library, if you want to just use it.
>
How much class instantiations does require this implementation? And what is
the total number of template arguments that will be created? I suspect that
the answer is O(N) and O(N^2) respectively, where N = sizeof...(Ts). I'd
like to have a solution requiring 0 or O(1) class instantiations.

--
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/2a160885-c82c-4741-8a8e-fc0fa75728a6%40isocpp.org.

------=_Part_482_47684529.1539288094341
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;bor=
der-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr">On Thursday, =
October 11, 2018 at 2:05:37 PM UTC-5, Andrey Davydov wrote:<blockquote clas=
s=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc =
solid;padding-left:1ex"><div dir=3D"ltr"><span style=3D"font-size:small">It=
&#39;s often needed to index into template parameter pack, when working wit=
h variadic templates, for instance in implementation of <font face=3D"couri=
er new, monospace">std::get&lt;size_t&gt;</font> of <font face=3D"courier n=
ew, monospace">tuple</font> and <font face=3D"courier new, monospace">varia=
nt</font>. I wonder if there is any proposal to add metafunction=C2=A0</spa=
n><div style=3D"background-color:rgb(250,250,250);border-color:rgb(187,187,=
187);border-style:solid;border-width:1px"><code><div><span style=3D"color:#=
008">&lt;std::size_t</span><span style=3D"color:#000"> </span><span style=
=3D"color:#606">I</span><span style=3D"color:#000">, </span><span style=3D"=
color:#606">typename</span><span style=3D"color:#000"> ...</span><span styl=
e=3D"color:#606">Ts</span><span style=3D"color:#008">&gt;</span><span style=
=3D"color:#000"><br>using type_pack_element =3D ...<br></span></div></code>=
</div><div><span style=3D"font-size:small">It</span><span style=3D"font-siz=
e:small">=C2=A0</span><span style=3D"font-size:small">can be implemented us=
ing existing language facilities or, similarly to <font face=3D"courier new=
, monospace">std::make_integer_sequence</font>, using compiler intrinsic. I=
t&#39;s already implemented in Clang (<font face=3D"courier new, monospace"=
>__type_pack_element</font>), and IMO it should not be hard to support in o=
ther compilers. Moreover it should be much more efficient from compile-time=
 perspective because variadic pack is stored in some vector-like data struc=
ture, and consequently to get element by index from it is much cheaper than=
 class template instantiation, overload resolution, etc...</span></div></di=
v></blockquote><div><br></div><div><a href=3D"http://www.open-std.org/jtc1/=
sc22/wg21/docs/papers/2018/p0949r0.html" target=3D"_blank" rel=3D"nofollow"=
 onmousedown=3D"this.href=3D&#39;http://www.google.com/url?q\x3dhttp%3A%2F%=
2Fwww.open-std.org%2Fjtc1%2Fsc22%2Fwg21%2Fdocs%2Fpapers%2F2018%2Fp0949r0.ht=
ml\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHuMDeR5gZ9U_-8Xw5sxn0jfQZ_4g&#39=
;;return true;" onclick=3D"this.href=3D&#39;http://www.google.com/url?q\x3d=
http%3A%2F%2Fwww.open-std.org%2Fjtc1%2Fsc22%2Fwg21%2Fdocs%2Fpapers%2F2018%2=
Fp0949r0.html\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHuMDeR5gZ9U_-8Xw5sxn0=
jfQZ_4g&#39;;return true;">http://www.open-std.org/jtc1/<wbr>sc22/wg21/docs=
/papers/2018/<wbr>p0949r0.html</a></div></div></blockquote><div>Thank you f=
or the link to this proposal.</div><blockquote class=3D"gmail_quote" style=
=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: =
1ex;"><div dir=3D"ltr"><div><br></div><div>What you&#39;re looking for is c=
alled mp_at_c in the proposal, except it takes a &quot;list&quot; as the fi=
rst parameter instead of a trailing template parameter. So yours implemente=
d in terms of that one would just be:</div><div><br></div><div><div style=
=3D"background-color:rgb(250,250,250);border-color:rgb(187,187,187);border-=
style:solid;border-width:1px"><code><div><span style=3D"color:#008">templat=
e</span><span style=3D"color:#000"> </span><span style=3D"color:#660">&lt;<=
/span><span style=3D"color:#000">size_t I</span><span style=3D"color:#660">=
,</span><font color=3D"#000000"><span style=3D"color:#000"> </span><span st=
yle=3D"color:#008">typename</span><span style=3D"color:#660">...</span><spa=
n style=3D"color:#000"> </span><span style=3D"color:#606">Ts</span><span st=
yle=3D"color:#660">&gt;</span><span style=3D"color:#000"><br></span><span s=
tyle=3D"color:#008">using</span><span style=3D"color:#000"> type_pack_eleme=
nt </span><span style=3D"color:#660">=3D</span><span style=3D"color:#000"> =
mp_at_c</span><span style=3D"color:#660">&lt;</span><span style=3D"color:#0=
00">mp_list</span><span style=3D"color:#660">&lt;</span><span style=3D"colo=
r:#606">Ts</span><span style=3D"color:#660">...&gt;,</span><span style=3D"c=
olor:#000"> I</span><span style=3D"color:#660">&gt;;</span></font><font col=
or=3D"#000000"></font></div></code></div><br>This is already in Boost as th=
e Mp11 library, if you want to just use it.</div></div></blockquote><div>Ho=
w much class instantiations does require this implementation? And what is t=
he total number of template arguments that will be created? I suspect that =
the answer is O(N) and O(N^2) respectively, where <font face=3D"courier new=
, monospace">N =3D sizeof...(Ts)</font>. I&#39;d like to have a solution re=
quiring 0 or O(1) class instantiations.</div>

<p></p>

-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/2a160885-c82c-4741-8a8e-fc0fa75728a6%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/2a160885-c82c-4741-8a8e-fc0fa75728a6=
%40isocpp.org</a>.<br />

------=_Part_482_47684529.1539288094341--

------=_Part_481_677548995.1539288094341--

.


Author: Barry Revzin <barry.revzin@gmail.com>
Date: Thu, 11 Oct 2018 13:11:50 -0700 (PDT)
Raw View
------=_Part_393_114870993.1539288710972
Content-Type: multipart/alternative;
 boundary="----=_Part_394_1194670931.1539288710972"

------=_Part_394_1194670931.1539288710972
Content-Type: text/plain; charset="UTF-8"



On Thursday, October 11, 2018 at 3:01:34 PM UTC-5, Andrey Davydov wrote:
>
> On Thursday, October 11, 2018 at 2:05:37 PM UTC-5, Andrey Davydov wrote:
>>>
>>> It's often needed to index into template parameter pack, when working
>>> with variadic templates, for instance in implementation of
>>> std::get<size_t> of tuple and variant. I wonder if there is any
>>> proposal to add metafunction
>>> <std::size_t I, typename ...Ts>
>>> using type_pack_element = ...
>>> It can be implemented using existing language facilities or, similarly
>>> to std::make_integer_sequence, using compiler intrinsic. It's already
>>> implemented in Clang (__type_pack_element), and IMO it should not be
>>> hard to support in other compilers. Moreover it should be much more
>>> efficient from compile-time perspective because variadic pack is stored in
>>> some vector-like data structure, and consequently to get element by index
>>> from it is much cheaper than class template instantiation, overload
>>> resolution, etc...
>>>
>>
>> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0949r0.html
>>
> Thank you for the link to this proposal.
>
>>
>> What you're looking for is called mp_at_c in the proposal, except it
>> takes a "list" as the first parameter instead of a trailing template
>> parameter. So yours implemented in terms of that one would just be:
>>
>> template <size_t I, typename... Ts>
>> using type_pack_element = mp_at_c<mp_list<Ts...>, I>;
>>
>> This is already in Boost as the Mp11 library, if you want to just use it.
>>
> How much class instantiations does require this implementation? And what
> is the total number of template arguments that will be created? I suspect
> that the answer is O(N) and O(N^2) respectively, where N = sizeof...(Ts).
> I'd like to have a solution requiring 0 or O(1) class instantiations.
>

Boost is open-source, you can look at the
implementation: https://github.com/boostorg/mp11/blob/develop/include/boost/mp11/algorithm.hpp#L305-L320

--
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/d7e9f74a-b4a4-4dca-a1f0-a4bdaa1d6180%40isocpp.org.

------=_Part_394_1194670931.1539288710972
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><br>On Thursday, October 11, 2018 at 3:01:34 PM UTC-5,=
 Andrey Davydov wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;=
margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><blockqu=
ote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1=
px #ccc solid;padding-left:1ex"><div dir=3D"ltr">On Thursday, October 11, 2=
018 at 2:05:37 PM UTC-5, Andrey Davydov wrote:<blockquote class=3D"gmail_qu=
ote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding=
-left:1ex"><div dir=3D"ltr"><span style=3D"font-size:small">It&#39;s often =
needed to index into template parameter pack, when working with variadic te=
mplates, for instance in implementation of <font face=3D"courier new, monos=
pace">std::get&lt;size_t&gt;</font> of <font face=3D"courier new, monospace=
">tuple</font> and <font face=3D"courier new, monospace">variant</font>. I =
wonder if there is any proposal to add metafunction=C2=A0</span><div style=
=3D"background-color:rgb(250,250,250);border-color:rgb(187,187,187);border-=
style:solid;border-width:1px"><code><div><span style=3D"color:#008">&lt;std=
::size_t</span><span style=3D"color:#000"> </span><span style=3D"color:#606=
">I</span><span style=3D"color:#000">, </span><span style=3D"color:#606">ty=
pename</span><span style=3D"color:#000"> ...</span><span style=3D"color:#60=
6">Ts</span><span style=3D"color:#008">&gt;</span><span style=3D"color:#000=
"><br>using type_pack_element =3D ...<br></span></div></code></div><div><sp=
an style=3D"font-size:small">It</span><span style=3D"font-size:small">=C2=
=A0</span><span style=3D"font-size:small">can be implemented using existing=
 language facilities or, similarly to <font face=3D"courier new, monospace"=
>std::make_integer_sequence</font>, using compiler intrinsic. It&#39;s alre=
ady implemented in Clang (<font face=3D"courier new, monospace">__type_pack=
_element</font>), and IMO it should not be hard to support in other compile=
rs. Moreover it should be much more efficient from compile-time perspective=
 because variadic pack is stored in some vector-like data structure, and co=
nsequently to get element by index from it is much cheaper than class templ=
ate instantiation, overload resolution, etc...</span></div></div></blockquo=
te><div><br></div><div><a href=3D"http://www.open-std.org/jtc1/sc22/wg21/do=
cs/papers/2018/p0949r0.html" rel=3D"nofollow" target=3D"_blank" onmousedown=
=3D"this.href=3D&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.open-s=
td.org%2Fjtc1%2Fsc22%2Fwg21%2Fdocs%2Fpapers%2F2018%2Fp0949r0.html\x26sa\x3d=
D\x26sntz\x3d1\x26usg\x3dAFQjCNHuMDeR5gZ9U_-8Xw5sxn0jfQZ_4g&#39;;return tru=
e;" onclick=3D"this.href=3D&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2=
Fwww.open-std.org%2Fjtc1%2Fsc22%2Fwg21%2Fdocs%2Fpapers%2F2018%2Fp0949r0.htm=
l\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHuMDeR5gZ9U_-8Xw5sxn0jfQZ_4g&#39;=
;return true;">http://www.open-std.org/jtc1/<wbr>sc22/wg21/docs/papers/2018=
/<wbr>p0949r0.html</a></div></div></blockquote><div>Thank you for the link =
to this proposal.</div><blockquote class=3D"gmail_quote" style=3D"margin:0;=
margin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"=
ltr"><div><br></div><div>What you&#39;re looking for is called mp_at_c in t=
he proposal, except it takes a &quot;list&quot; as the first parameter inst=
ead of a trailing template parameter. So yours implemented in terms of that=
 one would just be:</div><div><br></div><div><div style=3D"background-color=
:rgb(250,250,250);border-color:rgb(187,187,187);border-style:solid;border-w=
idth:1px"><code><div><span style=3D"color:#008">template</span><span style=
=3D"color:#000"> </span><span style=3D"color:#660">&lt;</span><span style=
=3D"color:#000">size_t I</span><span style=3D"color:#660">,</span><font col=
or=3D"#000000"><span style=3D"color:#000"> </span><span style=3D"color:#008=
">typename</span><span style=3D"color:#660">...</span><span style=3D"color:=
#000"> </span><span style=3D"color:#606">Ts</span><span style=3D"color:#660=
">&gt;</span><span style=3D"color:#000"><br></span><span style=3D"color:#00=
8">using</span><span style=3D"color:#000"> type_pack_element </span><span s=
tyle=3D"color:#660">=3D</span><span style=3D"color:#000"> mp_at_c</span><sp=
an style=3D"color:#660">&lt;</span><span style=3D"color:#000">mp_list</span=
><span style=3D"color:#660">&lt;</span><span style=3D"color:#606">Ts</span>=
<span style=3D"color:#660">...&gt;,</span><span style=3D"color:#000"> I</sp=
an><span style=3D"color:#660">&gt;;</span></font><font color=3D"#000000"></=
font></div></code></div><br>This is already in Boost as the Mp11 library, i=
f you want to just use it.</div></div></blockquote><div>How much class inst=
antiations does require this implementation? And what is the total number o=
f template arguments that will be created? I suspect that the answer is O(N=
) and O(N^2) respectively, where <font face=3D"courier new, monospace">N =
=3D sizeof...(Ts)</font>. I&#39;d like to have a solution requiring 0 or O(=
1) class instantiations.</div></blockquote><div><br></div><div>Boost is ope=
n-source, you can look at the implementation:=C2=A0https://github.com/boost=
org/mp11/blob/develop/include/boost/mp11/algorithm.hpp#L305-L320</div></div=
>

<p></p>

-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/d7e9f74a-b4a4-4dca-a1f0-a4bdaa1d6180%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/d7e9f74a-b4a4-4dca-a1f0-a4bdaa1d6180=
%40isocpp.org</a>.<br />

------=_Part_394_1194670931.1539288710972--

------=_Part_393_114870993.1539288710972--

.


Author: Andrey Davydov <andrey.a.davydov@gmail.com>
Date: Thu, 11 Oct 2018 13:17:57 -0700 (PDT)
Raw View
------=_Part_426_1374992870.1539289077425
Content-Type: multipart/alternative;
 boundary="----=_Part_427_1560112812.1539289077426"

------=_Part_427_1560112812.1539289077426
Content-Type: text/plain; charset="UTF-8"


>
> On Thursday, October 11, 2018 at 3:01:34 PM UTC-5, Andrey Davydov wrote:
>>
>> On Thursday, October 11, 2018 at 2:05:37 PM UTC-5, Andrey Davydov wrote:
>>>>
>>>> It's often needed to index into template parameter pack, when working
>>>> with variadic templates, for instance in implementation of
>>>> std::get<size_t> of tuple and variant. I wonder if there is any
>>>> proposal to add metafunction
>>>> <std::size_t I, typename ...Ts>
>>>> using type_pack_element = ...
>>>> It can be implemented using existing language facilities or, similarly
>>>> to std::make_integer_sequence, using compiler intrinsic. It's already
>>>> implemented in Clang (__type_pack_element), and IMO it should not be
>>>> hard to support in other compilers. Moreover it should be much more
>>>> efficient from compile-time perspective because variadic pack is stored in
>>>> some vector-like data structure, and consequently to get element by index
>>>> from it is much cheaper than class template instantiation, overload
>>>> resolution, etc...
>>>>
>>>
>>> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0949r0.html
>>>
>> Thank you for the link to this proposal.
>>
>>>
>>> What you're looking for is called mp_at_c in the proposal, except it
>>> takes a "list" as the first parameter instead of a trailing template
>>> parameter. So yours implemented in terms of that one would just be:
>>>
>>> template <size_t I, typename... Ts>
>>> using type_pack_element = mp_at_c<mp_list<Ts...>, I>;
>>>
>>> This is already in Boost as the Mp11 library, if you want to just use it.
>>>
>> How much class instantiations does require this implementation? And what
>> is the total number of template arguments that will be created? I suspect
>> that the answer is O(N) and O(N^2) respectively, where N = sizeof...(Ts).
>> I'd like to have a solution requiring 0 or O(1) class instantiations.
>>
>
> Boost is open-source, you can look at the implementation:
> https://github.com/boostorg/mp11/blob/develop/include/boost/mp11/algorithm.hpp#L305-L320
>
Ah, I see, where it's available Mp11 uses builtin __type_pack_element which
I suggest to standardize.

--
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/0004bbca-d6eb-4db2-8243-a5d31b80a1ba%40isocpp.org.

------=_Part_427_1560112812.1539289077426
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;bor=
der-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr">On Thursday, =
October 11, 2018 at 3:01:34 PM UTC-5, Andrey Davydov wrote:<blockquote clas=
s=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc =
solid;padding-left:1ex"><blockquote class=3D"gmail_quote" style=3D"margin:0=
;margin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D=
"ltr">On Thursday, October 11, 2018 at 2:05:37 PM UTC-5, Andrey Davydov wro=
te:<blockquote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;bo=
rder-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><span style=3D"=
font-size:small">It&#39;s often needed to index into template parameter pac=
k, when working with variadic templates, for instance in implementation of =
<font face=3D"courier new, monospace">std::get&lt;size_t&gt;</font> of <fon=
t face=3D"courier new, monospace">tuple</font> and <font face=3D"courier ne=
w, monospace">variant</font>. I wonder if there is any proposal to add meta=
function=C2=A0</span><div style=3D"background-color:rgb(250,250,250);border=
-color:rgb(187,187,187);border-style:solid;border-width:1px"><code><div><sp=
an style=3D"color:#008">&lt;std::size_t</span><span style=3D"color:#000"> <=
/span><span style=3D"color:#606">I</span><span style=3D"color:#000">, </spa=
n><span style=3D"color:#606">typename</span><span style=3D"color:#000"> ...=
</span><span style=3D"color:#606">Ts</span><span style=3D"color:#008">&gt;<=
/span><span style=3D"color:#000"><br>using type_pack_element =3D ...<br></s=
pan></div></code></div><div><span style=3D"font-size:small">It</span><span =
style=3D"font-size:small">=C2=A0</span><span style=3D"font-size:small">can =
be implemented using existing language facilities or, similarly to <font fa=
ce=3D"courier new, monospace">std::make_integer_sequence</font>, using comp=
iler intrinsic. It&#39;s already implemented in Clang (<font face=3D"courie=
r new, monospace">__type_pack_element</font>), and IMO it should not be har=
d to support in other compilers. Moreover it should be much more efficient =
from compile-time perspective because variadic pack is stored in some vecto=
r-like data structure, and consequently to get element by index from it is =
much cheaper than class template instantiation, overload resolution, etc...=
</span></div></div></blockquote><div><br></div><div><a href=3D"http://www.o=
pen-std.org/jtc1/sc22/wg21/docs/papers/2018/p0949r0.html" rel=3D"nofollow" =
target=3D"_blank" onmousedown=3D"this.href=3D&#39;http://www.google.com/url=
?q\x3dhttp%3A%2F%2Fwww.open-std.org%2Fjtc1%2Fsc22%2Fwg21%2Fdocs%2Fpapers%2F=
2018%2Fp0949r0.html\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHuMDeR5gZ9U_-8X=
w5sxn0jfQZ_4g&#39;;return true;" onclick=3D"this.href=3D&#39;http://www.goo=
gle.com/url?q\x3dhttp%3A%2F%2Fwww.open-std.org%2Fjtc1%2Fsc22%2Fwg21%2Fdocs%=
2Fpapers%2F2018%2Fp0949r0.html\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHuMD=
eR5gZ9U_-8Xw5sxn0jfQZ_4g&#39;;return true;">http://www.open-std.org/jtc1/<w=
br>sc22/wg21/docs/papers/2018/<wbr>p0949r0.html</a></div></div></blockquote=
><div>Thank you for the link to this proposal.</div><blockquote class=3D"gm=
ail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;p=
adding-left:1ex"><div dir=3D"ltr"><div><br></div><div>What you&#39;re looki=
ng for is called mp_at_c in the proposal, except it takes a &quot;list&quot=
; as the first parameter instead of a trailing template parameter. So yours=
 implemented in terms of that one would just be:</div><div><br></div><div><=
div style=3D"background-color:rgb(250,250,250);border-color:rgb(187,187,187=
);border-style:solid;border-width:1px"><code><div><span style=3D"color:#008=
">template</span><span style=3D"color:#000"> </span><span style=3D"color:#6=
60">&lt;</span><span style=3D"color:#000">size_t I</span><span style=3D"col=
or:#660">,</span><font color=3D"#000000"><span style=3D"color:#000"> </span=
><span style=3D"color:#008">typename</span><span style=3D"color:#660">...</=
span><span style=3D"color:#000"> </span><span style=3D"color:#606">Ts</span=
><span style=3D"color:#660">&gt;</span><span style=3D"color:#000"><br></spa=
n><span style=3D"color:#008">using</span><span style=3D"color:#000"> type_p=
ack_element </span><span style=3D"color:#660">=3D</span><span style=3D"colo=
r:#000"> mp_at_c</span><span style=3D"color:#660">&lt;</span><span style=3D=
"color:#000">mp_list</span><span style=3D"color:#660">&lt;</span><span styl=
e=3D"color:#606">Ts</span><span style=3D"color:#660">...&gt;,</span><span s=
tyle=3D"color:#000"> I</span><span style=3D"color:#660">&gt;;</span></font>=
<font color=3D"#000000"></font></div></code></div><br>This is already in Bo=
ost as the Mp11 library, if you want to just use it.</div></div></blockquot=
e><div>How much class instantiations does require this implementation? And =
what is the total number of template arguments that will be created? I susp=
ect that the answer is O(N) and O(N^2) respectively, where <font face=3D"co=
urier new, monospace">N =3D sizeof...(Ts)</font>. I&#39;d like to have a so=
lution requiring 0 or O(1) class instantiations.</div></blockquote><div><br=
></div><div>Boost is open-source, you can look at the implementation:=C2=A0=
<a href=3D"https://github.com/boostorg/mp11/blob/develop/include/boost/mp11=
/algorithm.hpp#L305-L320" target=3D"_blank" rel=3D"nofollow" onmousedown=3D=
"this.href=3D&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%=
2Fboostorg%2Fmp11%2Fblob%2Fdevelop%2Finclude%2Fboost%2Fmp11%2Falgorithm.hpp=
%23L305-L320\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHUeWIbcXpm2SppmGK5_iRI=
krN9IQ&#39;;return true;" onclick=3D"this.href=3D&#39;https://www.google.co=
m/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fboostorg%2Fmp11%2Fblob%2Fdevelop%2Fin=
clude%2Fboost%2Fmp11%2Falgorithm.hpp%23L305-L320\x26sa\x3dD\x26sntz\x3d1\x2=
6usg\x3dAFQjCNHUeWIbcXpm2SppmGK5_iRIkrN9IQ&#39;;return true;">https://<wbr>=
github.com/boostorg/mp11/blob/<wbr>develop/include/boost/mp11/<wbr>algorith=
m.hpp#L305-L320</a></div></div></blockquote><div>Ah, I see, where it&#39;s =
available Mp11 uses builtin <font face=3D"courier new, monospace">__type_pa=
ck_element=C2=A0</font><font face=3D"arial, sans-serif">which I suggest to=
=C2=A0standardize.</font></div>

<p></p>

-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/0004bbca-d6eb-4db2-8243-a5d31b80a1ba%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/0004bbca-d6eb-4db2-8243-a5d31b80a1ba=
%40isocpp.org</a>.<br />

------=_Part_427_1560112812.1539289077426--

------=_Part_426_1374992870.1539289077425--

.


Author: Bryce Adelstein Lelbach aka wash <brycelelbach@gmail.com>
Date: Sat, 20 Oct 2018 10:11:34 -0400
Raw View
--000000000000ac9a200578a99968
Content-Type: text/plain; charset="UTF-8"

This seems like a useful facility, although I wonder if language support
for random access to packs would be more elegant.

What happened to P0949? Was it reviewed?

On Thu, Oct 11, 2018, 4:17 PM Andrey Davydov <andrey.a.davydov@gmail.com>
wrote:

> On Thursday, October 11, 2018 at 3:01:34 PM UTC-5, Andrey Davydov wrote:
>>>
>>> On Thursday, October 11, 2018 at 2:05:37 PM UTC-5, Andrey Davydov wrote:
>>>>>
>>>>> It's often needed to index into template parameter pack, when working
>>>>> with variadic templates, for instance in implementation of
>>>>> std::get<size_t> of tuple and variant. I wonder if there is any
>>>>> proposal to add metafunction
>>>>> <std::size_t I, typename ...Ts>
>>>>> using type_pack_element = ...
>>>>> It can be implemented using existing language facilities or,
>>>>> similarly to std::make_integer_sequence, using compiler intrinsic.
>>>>> It's already implemented in Clang (__type_pack_element), and IMO it
>>>>> should not be hard to support in other compilers. Moreover it should be
>>>>> much more efficient from compile-time perspective because variadic pack is
>>>>> stored in some vector-like data structure, and consequently to get element
>>>>> by index from it is much cheaper than class template instantiation,
>>>>> overload resolution, etc...
>>>>>
>>>>
>>>> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0949r0.html
>>>>
>>> Thank you for the link to this proposal.
>>>
>>>>
>>>> What you're looking for is called mp_at_c in the proposal, except it
>>>> takes a "list" as the first parameter instead of a trailing template
>>>> parameter. So yours implemented in terms of that one would just be:
>>>>
>>>> template <size_t I, typename... Ts>
>>>> using type_pack_element = mp_at_c<mp_list<Ts...>, I>;
>>>>
>>>> This is already in Boost as the Mp11 library, if you want to just use
>>>> it.
>>>>
>>> How much class instantiations does require this implementation? And what
>>> is the total number of template arguments that will be created? I suspect
>>> that the answer is O(N) and O(N^2) respectively, where N = sizeof...(Ts).
>>> I'd like to have a solution requiring 0 or O(1) class instantiations.
>>>
>>
>> Boost is open-source, you can look at the implementation:
>> https://github.com/boostorg/mp11/blob/develop/include/boost/mp11/algorithm.hpp#L305-L320
>>
> Ah, I see, where it's available Mp11 uses builtin __type_pack_element which
> I suggest to standardize.
>
> --
> 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/0004bbca-d6eb-4db2-8243-a5d31b80a1ba%40isocpp.org
> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/0004bbca-d6eb-4db2-8243-a5d31b80a1ba%40isocpp.org?utm_medium=email&utm_source=footer>
> .
>

--
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/CAP3wax_%2BL%3Dj0q_YXH3ptLj_-C4n2yBb5%3D0uBkzmr77GXcqs%2BDA%40mail.gmail.com.

--000000000000ac9a200578a99968
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"auto"><div>This seems like a useful facility, although I wonder=
 if language support for random access to packs would be more elegant.<div =
dir=3D"auto"><br></div><div dir=3D"auto">What happened to P0949? Was it rev=
iewed?</div><br><div class=3D"gmail_quote"><div dir=3D"ltr">On Thu, Oct 11,=
 2018, 4:17 PM Andrey Davydov &lt;<a href=3D"mailto:andrey.a.davydov@gmail.=
com" target=3D"_blank" rel=3D"noreferrer">andrey.a.davydov@gmail.com</a>&gt=
; wrote:<br></div><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .=
8ex;border-left:1px #ccc solid;padding-left:1ex"><blockquote class=3D"gmail=
_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padd=
ing-left:1ex"><div dir=3D"ltr">On Thursday, October 11, 2018 at 3:01:34 PM =
UTC-5, Andrey Davydov wrote:<blockquote class=3D"gmail_quote" style=3D"marg=
in:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex"><blockq=
uote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:=
1px #ccc solid;padding-left:1ex"><div dir=3D"ltr">On Thursday, October 11, =
2018 at 2:05:37 PM UTC-5, Andrey Davydov wrote:<blockquote class=3D"gmail_q=
uote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;paddin=
g-left:1ex"><div dir=3D"ltr"><span style=3D"font-size:small">It&#39;s often=
 needed to index into template parameter pack, when working with variadic t=
emplates, for instance in implementation of <font face=3D"courier new, mono=
space">std::get&lt;size_t&gt;</font> of <font face=3D"courier new, monospac=
e">tuple</font> and <font face=3D"courier new, monospace">variant</font>. I=
 wonder if there is any proposal to add metafunction=C2=A0</span><div style=
=3D"background-color:rgb(250,250,250);border-color:rgb(187,187,187);border-=
style:solid;border-width:1px"><code><div><span style=3D"color:#008">&lt;std=
::size_t</span><span style=3D"color:#000"> </span><span style=3D"color:#606=
">I</span><span style=3D"color:#000">, </span><span style=3D"color:#606">ty=
pename</span><span style=3D"color:#000"> ...</span><span style=3D"color:#60=
6">Ts</span><span style=3D"color:#008">&gt;</span><span style=3D"color:#000=
"><br>using type_pack_element =3D ...<br></span></div></code></div><div><sp=
an style=3D"font-size:small">It</span><span style=3D"font-size:small">=C2=
=A0</span><span style=3D"font-size:small">can be implemented using existing=
 language facilities or, similarly to <font face=3D"courier new, monospace"=
>std::make_integer_sequence</font>, using compiler intrinsic. It&#39;s alre=
ady implemented in Clang (<font face=3D"courier new, monospace">__type_pack=
_element</font>), and IMO it should not be hard to support in other compile=
rs. Moreover it should be much more efficient from compile-time perspective=
 because variadic pack is stored in some vector-like data structure, and co=
nsequently to get element by index from it is much cheaper than class templ=
ate instantiation, overload resolution, etc...</span></div></div></blockquo=
te><div><br></div><div><a href=3D"http://www.open-std.org/jtc1/sc22/wg21/do=
cs/papers/2018/p0949r0.html" rel=3D"nofollow noreferrer noreferrer" target=
=3D"_blank">http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0949r0=
..html</a></div></div></blockquote><div>Thank you for the link to this propo=
sal.</div><blockquote class=3D"gmail_quote" style=3D"margin:0;margin-left:0=
..8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><div><br=
></div><div>What you&#39;re looking for is called mp_at_c in the proposal, =
except it takes a &quot;list&quot; as the first parameter instead of a trai=
ling template parameter. So yours implemented in terms of that one would ju=
st be:</div><div><br></div><div><div style=3D"background-color:rgb(250,250,=
250);border-color:rgb(187,187,187);border-style:solid;border-width:1px"><co=
de><div><span style=3D"color:#008">template</span><span style=3D"color:#000=
"> </span><span style=3D"color:#660">&lt;</span><span style=3D"color:#000">=
size_t I</span><span style=3D"color:#660">,</span><font color=3D"#000000"><=
span style=3D"color:#000"> </span><span style=3D"color:#008">typename</span=
><span style=3D"color:#660">...</span><span style=3D"color:#000"> </span><s=
pan style=3D"color:#606">Ts</span><span style=3D"color:#660">&gt;</span><sp=
an style=3D"color:#000"><br></span><span style=3D"color:#008">using</span><=
span style=3D"color:#000"> type_pack_element </span><span style=3D"color:#6=
60">=3D</span><span style=3D"color:#000"> mp_at_c</span><span style=3D"colo=
r:#660">&lt;</span><span style=3D"color:#000">mp_list</span><span style=3D"=
color:#660">&lt;</span><span style=3D"color:#606">Ts</span><span style=3D"c=
olor:#660">...&gt;,</span><span style=3D"color:#000"> I</span><span style=
=3D"color:#660">&gt;;</span></font><font color=3D"#000000"></font></div></c=
ode></div><br>This is already in Boost as the Mp11 library, if you want to =
just use it.</div></div></blockquote><div>How much class instantiations doe=
s require this implementation? And what is the total number of template arg=
uments that will be created? I suspect that the answer is O(N) and O(N^2) r=
espectively, where <font face=3D"courier new, monospace">N =3D sizeof...(Ts=
)</font>. I&#39;d like to have a solution requiring 0 or O(1) class instant=
iations.</div></blockquote><div><br></div><div>Boost is open-source, you ca=
n look at the implementation:=C2=A0<a href=3D"https://github.com/boostorg/m=
p11/blob/develop/include/boost/mp11/algorithm.hpp#L305-L320" rel=3D"nofollo=
w noreferrer noreferrer" target=3D"_blank">https://github.com/boostorg/mp11=
/blob/develop/include/boost/mp11/algorithm.hpp#L305-L320</a></div></div></b=
lockquote><div>Ah, I see, where it&#39;s available Mp11 uses builtin <font =
face=3D"courier new, monospace">__type_pack_element=C2=A0</font><font face=
=3D"arial, sans-serif">which I suggest to=C2=A0standardize.</font></div>

<p></p>

-- <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" rel=3D"nore=
ferrer noreferrer" target=3D"_blank">std-proposals+unsubscribe@isocpp.org</=
a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" rel=3D"noreferrer noreferrer" target=3D"_blank">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/0004bbca-d6eb-4db2-8243-a5d31b80a1ba%=
40isocpp.org?utm_medium=3Demail&amp;utm_source=3Dfooter" rel=3D"noreferrer =
noreferrer" target=3D"_blank">https://groups.google.com/a/isocpp.org/d/msgi=
d/std-proposals/0004bbca-d6eb-4db2-8243-a5d31b80a1ba%40isocpp.org</a>.<br>
</blockquote></div>
</div></div>

<p></p>

-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CAP3wax_%2BL%3Dj0q_YXH3ptLj_-C4n2yBb5=
%3D0uBkzmr77GXcqs%2BDA%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfoo=
ter">https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAP3wax_%=
2BL%3Dj0q_YXH3ptLj_-C4n2yBb5%3D0uBkzmr77GXcqs%2BDA%40mail.gmail.com</a>.<br=
 />

--000000000000ac9a200578a99968--

.


Author: Matthew Woehlke <mwoehlke.floss@gmail.com>
Date: Wed, 24 Oct 2018 12:17:53 -0400
Raw View
On 20/10/2018 10.11, Bryce Adelstein Lelbach aka wash wrote:
> This seems like a useful facility, although I wonder if language support
> for random access to packs would be more elegant.

Well, *I* sure thought so... see P0535.

> What happened to P0949? Was it reviewed?

Hadn't seen that before. I am disappointed that it doesn't even mention
P0535.

--
Matthew

--
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/2cfe3cde-4fed-cea8-5c09-f91f1664b4bd%40gmail.com.

.


Author: Victor Dyachenko <victor.dyachenko@gmail.com>
Date: Thu, 25 Oct 2018 01:16:56 -0700 (PDT)
Raw View
------=_Part_229_575184394.1540455416208
Content-Type: multipart/alternative;
 boundary="----=_Part_230_843209329.1540455416208"

------=_Part_230_843209329.1540455416208
Content-Type: text/plain; charset="UTF-8"

Is std::type_pack_element<2,int> just ill-formed or it's a SFINAE?

--
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/6152abe7-3660-45d6-81f6-de2d81e310e8%40isocpp.org.

------=_Part_230_843209329.1540455416208
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Is <span style=3D"font-family: courier new, monospace;">st=
d::type_pack_element&lt;2,int&gt;</span> just ill-formed or it&#39;s a SFIN=
AE?<br></div>

<p></p>

-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/6152abe7-3660-45d6-81f6-de2d81e310e8%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/6152abe7-3660-45d6-81f6-de2d81e310e8=
%40isocpp.org</a>.<br />

------=_Part_230_843209329.1540455416208--

------=_Part_229_575184394.1540455416208--

.


Author: Andrey Davydov <andrey.a.davydov@gmail.com>
Date: Thu, 25 Oct 2018 01:41:31 -0700 (PDT)
Raw View
------=_Part_230_610939951.1540456891787
Content-Type: multipart/alternative;
 boundary="----=_Part_231_1297143088.1540456891787"

------=_Part_231_1297143088.1540456891787
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Implemented in Clang now __type_pack_element supports SFINAE=20
(https://godbolt.org/z/g_pIpH), but std::tuple_element_t doesn't.
Do you see some cases where support of SFINAE would be useful?

=D1=87=D0=B5=D1=82=D0=B2=D0=B5=D1=80=D0=B3, 25 =D0=BE=D0=BA=D1=82=D1=8F=D0=
=B1=D1=80=D1=8F 2018 =D0=B3., 11:16:56 UTC+3 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=
=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C Victor Dyachenko=20
=D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:
>
> Is std::type_pack_element<2,int> just ill-formed or it's a SFINAE?
>

--=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.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/256afdb5-3a16-4f08-b39c-cb44a1cb4c78%40isocpp.or=
g.

------=_Part_231_1297143088.1540456891787
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Implemented in Clang now <font face=3D"courier new, monosp=
ace">__type_pack_element</font> supports SFINAE (https://godbolt.org/z/g_pI=
pH), but <font face=3D"courier new, monospace">std::tuple_element_t</font> =
doesn&#39;t.<div>Do you see some cases where support of SFINAE would be use=
ful?<br><br>=D1=87=D0=B5=D1=82=D0=B2=D0=B5=D1=80=D0=B3, 25 =D0=BE=D0=BA=D1=
=82=D1=8F=D0=B1=D1=80=D1=8F 2018 =D0=B3., 11:16:56 UTC+3 =D0=BF=D0=BE=D0=BB=
=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C Victor Dyachenko =D0=
=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:<blockquote class=3D"gmail_quote" s=
tyle=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-le=
ft: 1ex;"><div dir=3D"ltr">Is <span style=3D"font-family:courier new,monosp=
ace">std::type_pack_element&lt;2,int&gt;</span> just ill-formed or it&#39;s=
 a SFINAE?<br></div></blockquote></div></div>

<p></p>

-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/256afdb5-3a16-4f08-b39c-cb44a1cb4c78%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/256afdb5-3a16-4f08-b39c-cb44a1cb4c78=
%40isocpp.org</a>.<br />

------=_Part_231_1297143088.1540456891787--

------=_Part_230_610939951.1540456891787--

.


Author: Victor Dyachenko <victor.dyachenko@gmail.com>
Date: Thu, 25 Oct 2018 01:57:23 -0700 (PDT)
Raw View
------=_Part_276_1452801107.1540457843379
Content-Type: multipart/alternative;
 boundary="----=_Part_277_1668001168.1540457843379"

------=_Part_277_1668001168.1540457843379
Content-Type: text/plain; charset="UTF-8"

On Thursday, October 25, 2018 at 11:41:31 AM UTC+3, Andrey Davydov wrote:
>
> Implemented in Clang now __type_pack_element supports SFINAE (
> https://godbolt.org/z/g_pIpH), but std::tuple_element_t doesn't.
> Do you see some cases where support of SFINAE would be useful?
>

Can't  recall at the moment... But I have analogous class in my code and 3
years ago made it SFINAE-friendly. AFAIK it gives more sensible error
messages on errors and in some cases static_asserts are just able to fire.

--
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/0efccfd2-ef64-4eaa-9705-ffa6bb557aec%40isocpp.org.

------=_Part_277_1668001168.1540457843379
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">On Thursday, October 25, 2018 at 11:41:31 AM UTC+3, Andrey=
 Davydov wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-=
left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr=
">Implemented in Clang now <font face=3D"courier new, monospace">__type_pac=
k_element</font> supports SFINAE (<a href=3D"https://godbolt.org/z/g_pIpH" =
target=3D"_blank" rel=3D"nofollow" onmousedown=3D"this.href=3D&#39;https://=
www.google.com/url?q\x3dhttps%3A%2F%2Fgodbolt.org%2Fz%2Fg_pIpH\x26sa\x3dD\x=
26sntz\x3d1\x26usg\x3dAFQjCNFJLuEnaKE_ntz6gh5jhB4Y5ZN98w&#39;;return true;"=
 onclick=3D"this.href=3D&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2F=
godbolt.org%2Fz%2Fg_pIpH\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFJLuEnaKE_=
ntz6gh5jhB4Y5ZN98w&#39;;return true;">https://godbolt.org/z/g_pIpH</a>)<wbr=
>, but <font face=3D"courier new, monospace">std::tuple_element_t</font> do=
esn&#39;t.<div>Do you see some cases where support of SFINAE would be usefu=
l?<br></div></div></blockquote><div><br></div><div>Can&#39;t=C2=A0 recall a=
t the moment... But I have analogous class in my code and 3 years ago made =
it SFINAE-friendly. AFAIK it gives more sensible error messages on errors a=
nd in some cases static_asserts are just able to fire.<br></div></div>

<p></p>

-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/0efccfd2-ef64-4eaa-9705-ffa6bb557aec%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/0efccfd2-ef64-4eaa-9705-ffa6bb557aec=
%40isocpp.org</a>.<br />

------=_Part_277_1668001168.1540457843379--

------=_Part_276_1452801107.1540457843379--

.


Author: Louis Dionne <ldionne.2@gmail.com>
Date: Thu, 1 Nov 2018 15:43:58 -0700 (PDT)
Raw View
------=_Part_549_789485508.1541112238820
Content-Type: multipart/alternative;
 boundary="----=_Part_550_94056759.1541112238820"

------=_Part_550_94056759.1541112238820
Content-Type: text/plain; charset="UTF-8"

Sorry for being late in the game. I originally implemented
__type_pack_element in Clang as a workaround for the lack of efficient ways
to index parameter packs in the context of template based metaprogramming.
At this moment, I do not think that standardizing this facility is a good
idea.

C++ wants to move away of template-based metaprogramming and into constexpr
value metaprogramming. This is a rather long journey, but the idea is that
std::vector should be your type list of the future. In a world like that,
indexing a type list can be done with operator[] on the vector, and that
should be O(1) compile-time.

Just my .02,
Louis

On Thursday, 11 October 2018 15:05:37 UTC-4, Andrey Davydov wrote:
>
> It's often needed to index into template parameter pack, when working with
> variadic templates, for instance in implementation of std::get<size_t> of
> tuple and variant. I wonder if there is any proposal to add metafunction
> <std::size_t I, typename ...Ts>
> using type_pack_element = ...
> It can be implemented using existing language facilities or, similarly to
> std::make_integer_sequence, using compiler intrinsic. It's already
> implemented in Clang (__type_pack_element), and IMO it should not be hard
> to support in other compilers. Moreover it should be much more efficient
> from compile-time perspective because variadic pack is stored in some
> vector-like data structure, and consequently to get element by index from
> it is much cheaper than class template instantiation, overload resolution,
> etc...
>

--
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/114ad1ef-297f-47dc-aa22-881a9f7a702c%40isocpp.org.

------=_Part_550_94056759.1541112238820
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Sorry for being late in the game. I originally implemented=
=C2=A0<span style=3D"font-family: &quot;courier new&quot;, monospace; font-=
size: small;">__type_pack_element</span>=C2=A0in Clang as a workaround for =
the lack of efficient ways to index parameter packs in the context of templ=
ate based metaprogramming. At this moment, I do not think that standardizin=
g this facility is a good idea.<div><br></div><div>C++ wants to move away o=
f template-based metaprogramming and into constexpr value metaprogramming. =
This is a rather long journey, but the idea is that std::vector should be y=
our type list of the future. In a world like that, indexing a type list can=
 be done with operator[] on the vector, and that should be O(1) compile-tim=
e.</div><div><br></div><div>Just my .02,</div><div>Louis<br><br>On Thursday=
, 11 October 2018 15:05:37 UTC-4, Andrey Davydov  wrote:<blockquote class=
=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #cc=
c solid;padding-left: 1ex;"><div dir=3D"ltr"><span style=3D"font-size:small=
">It&#39;s often needed to index into template parameter pack, when working=
 with variadic templates, for instance in implementation of <font face=3D"c=
ourier new, monospace">std::get&lt;size_t&gt;</font> of <font face=3D"couri=
er new, monospace">tuple</font> and <font face=3D"courier new, monospace">v=
ariant</font>. I wonder if there is any proposal to add metafunction=C2=A0<=
/span><div style=3D"background-color:rgb(250,250,250);border-color:rgb(187,=
187,187);border-style:solid;border-width:1px"><code><div><span style=3D"col=
or:#008">&lt;std::size_t</span><span style=3D"color:#000"> </span><span sty=
le=3D"color:#606">I</span><span style=3D"color:#000">, </span><span style=
=3D"color:#606">typename</span><span style=3D"color:#000"> ...</span><span =
style=3D"color:#606">Ts</span><span style=3D"color:#008">&gt;</span><span s=
tyle=3D"color:#000"><br>using type_pack_element =3D ...<br></span></div></c=
ode></div><div><span style=3D"font-size:small">It</span><span style=3D"font=
-size:small">=C2=A0</span><span style=3D"font-size:small">can be implemente=
d using existing language facilities or, similarly to <font face=3D"courier=
 new, monospace">std::make_integer_sequence</font>, using compiler intrinsi=
c. It&#39;s already implemented in Clang (<font face=3D"courier new, monosp=
ace">__type_pack_element</font>), and IMO it should not be hard to support =
in other compilers. Moreover it should be much more efficient from compile-=
time perspective because variadic pack is stored in some vector-like data s=
tructure, and consequently to get element by index from it is much cheaper =
than class template instantiation, overload resolution, etc...</span></div>=
</div></blockquote></div></div>

<p></p>

-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/114ad1ef-297f-47dc-aa22-881a9f7a702c%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/114ad1ef-297f-47dc-aa22-881a9f7a702c=
%40isocpp.org</a>.<br />

------=_Part_550_94056759.1541112238820--

------=_Part_549_789485508.1541112238820--

.


Author: cppljevans@gmail.com
Date: Thu, 1 Nov 2018 22:48:26 -0700 (PDT)
Raw View
------=_Part_684_1745722583.1541137706365
Content-Type: multipart/alternative;
 boundary="----=_Part_685_1337483591.1541137706365"

------=_Part_685_1337483591.1541137706365
Content-Type: text/plain; charset="UTF-8"



On Thursday, November 1, 2018 at 5:43:58 PM UTC-5, Louis Dionne wrote:
>
> Sorry for being late in the game. I originally implemented
> __type_pack_element in Clang as a workaround for the lack of efficient
> ways to index parameter packs in the context of template based
> metaprogramming. At this moment, I do not think that standardizing this
> facility is a good idea.
>
> C++ wants to move away of template-based metaprogramming and into
> constexpr value metaprogramming. This is a rather long journey, but the
> idea is that std::vector should be your type list of the future. In a world
> like that, indexing a type list can be done with operator[] on the vector,
> and that should be O(1) compile-time.
>
> Just my .02,
> Louis
>
 Louis, I don't see how:

template < typename T, typename Alloc = allocator<T> > class vector;

could be used to index into a pack of types since there's
only one type, T, in the template.  I'm guessing you mean
something else?  Maybe:

template< typename[1] T > class vector;

where typename[1] is a new notation meaning maybe something
like a metaclass or maybe a type of types?  And maybe
typename[2] means a type of typename[1]'s?

Could you please provide some more details of how a
std::vector could be used to solve the OP problem?

-Larry

>
> On Thursday, 11 October 2018 15:05:37 UTC-4, Andrey Davydov wrote:
>>
>> It's often needed to index into template parameter pack, when working
>> with variadic templates, for instance in implementation of
>> std::get<size_t> of tuple and variant. I wonder if there is any proposal
>> to add metafunction
>> <std::size_t I, typename ...Ts>
>> using type_pack_element = ...
>> It can be implemented using existing language facilities or, similarly
>> to std::make_integer_sequence, using compiler intrinsic. It's already
>> implemented in Clang (__type_pack_element), and IMO it should not be
>> hard to support in other compilers. Moreover it should be much more
>> efficient from compile-time perspective because variadic pack is stored in
>> some vector-like data structure, and consequently to get element by index
>> from it is much cheaper than class template instantiation, overload
>> resolution, etc...
>>
>

--
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/a9f1d81b-bc39-4659-ba14-42a2fa354c3d%40isocpp.org.

------=_Part_685_1337483591.1541137706365
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><br>On Thursday, November 1, 2018 at 5:43:58 PM UTC-5,=
 Louis Dionne wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;ma=
rgin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=
=3D"ltr">Sorry for being late in the game. I originally implemented=C2=A0<s=
pan style=3D"font-family:&quot;courier new&quot;,monospace;font-size:small"=
>__type_pack_<wbr>element</span>=C2=A0in Clang as a workaround for the lack=
 of efficient ways to index parameter packs in the context of template base=
d metaprogramming. At this moment, I do not think that standardizing this f=
acility is a good idea.<div><br></div><div>C++ wants to move away of templa=
te-based metaprogramming and into constexpr value metaprogramming. This is =
a rather long journey, but the idea is that std::vector should be your type=
 list of the future. In a world like that, indexing a type list can be done=
 with operator[] on the vector, and that should be O(1) compile-time.</div>=
<div><br></div><div>Just my .02,</div><div>Louis<br></div></div></blockquot=
e><div>=C2=A0Louis, I don&#39;t see how:<br><br>template &lt; typename T, t=
ypename Alloc =3D allocator&lt;T&gt; &gt; class vector; <br><br>could be us=
ed to index into a pack of types since there&#39;s<br>only one type, T, in =
the template.=C2=A0 I&#39;m guessing you mean<br>something else?=C2=A0 Mayb=
e:<br><br>template&lt; typename[1] T &gt; class vector;<br><br>where typena=
me[1] is a new notation meaning maybe something<br>like a metaclass or mayb=
e a type of types?=C2=A0 And maybe<br>typename[2] means a type of typename[=
1]&#39;s?<br><br>Could you please provide some more details of how a<br>std=
::vector could be used to solve the OP problem?<br><br>-Larry</div><blockqu=
ote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left=
: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><div><br>On Thursday,=
 11 October 2018 15:05:37 UTC-4, Andrey Davydov  wrote:<blockquote class=3D=
"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc soli=
d;padding-left:1ex"><div dir=3D"ltr"><span style=3D"font-size:small">It&#39=
;s often needed to index into template parameter pack, when working with va=
riadic templates, for instance in implementation of <font face=3D"courier n=
ew, monospace">std::get&lt;size_t&gt;</font> of <font face=3D"courier new, =
monospace">tuple</font> and <font face=3D"courier new, monospace">variant</=
font>. I wonder if there is any proposal to add metafunction=C2=A0</span><d=
iv style=3D"background-color:rgb(250,250,250);border-color:rgb(187,187,187)=
;border-style:solid;border-width:1px"><code><div><span style=3D"color:#008"=
>&lt;std::size_t</span><span style=3D"color:#000"> </span><span style=3D"co=
lor:#606">I</span><span style=3D"color:#000">, </span><span style=3D"color:=
#606">typename</span><span style=3D"color:#000"> ...</span><span style=3D"c=
olor:#606">Ts</span><span style=3D"color:#008">&gt;</span><span style=3D"co=
lor:#000"><br>using type_pack_element =3D ...<br></span></div></code></div>=
<div><span style=3D"font-size:small">It</span><span style=3D"font-size:smal=
l">=C2=A0</span><span style=3D"font-size:small">can be implemented using ex=
isting language facilities or, similarly to <font face=3D"courier new, mono=
space">std::make_integer_sequence</font>, using compiler intrinsic. It&#39;=
s already implemented in Clang (<font face=3D"courier new, monospace">__typ=
e_pack_element</font>), and IMO it should not be hard to support in other c=
ompilers. Moreover it should be much more efficient from compile-time persp=
ective because variadic pack is stored in some vector-like data structure, =
and consequently to get element by index from it is much cheaper than class=
 template instantiation, overload resolution, etc...</span></div></div></bl=
ockquote></div></div></blockquote></div>

<p></p>

-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/a9f1d81b-bc39-4659-ba14-42a2fa354c3d%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/a9f1d81b-bc39-4659-ba14-42a2fa354c3d=
%40isocpp.org</a>.<br />

------=_Part_685_1337483591.1541137706365--

------=_Part_684_1745722583.1541137706365--

.


Author: Justin Bassett <jbassett271@gmail.com>
Date: Fri, 2 Nov 2018 08:31:03 -0700
Raw View
--000000000000efd0ad0579b0391a
Content-Type: text/plain; charset="UTF-8"

I believe the intent is something like  `std::vector<std::type>` where
`std::type` is a value representing a type. So, instead of `template
<typename... Ts>`, you would store each T as a value in the vector.

On Thu, Nov 1, 2018, 10:48 PM <cppljevans@gmail.com wrote:

>
>
> On Thursday, November 1, 2018 at 5:43:58 PM UTC-5, Louis Dionne wrote:
>>
>> Sorry for being late in the game. I originally implemented
>> __type_pack_element in Clang as a workaround for the lack of efficient
>> ways to index parameter packs in the context of template based
>> metaprogramming. At this moment, I do not think that standardizing this
>> facility is a good idea.
>>
>> C++ wants to move away of template-based metaprogramming and into
>> constexpr value metaprogramming. This is a rather long journey, but the
>> idea is that std::vector should be your type list of the future. In a world
>> like that, indexing a type list can be done with operator[] on the vector,
>> and that should be O(1) compile-time.
>>
>> Just my .02,
>> Louis
>>
>  Louis, I don't see how:
>
> template < typename T, typename Alloc = allocator<T> > class vector;
>
> could be used to index into a pack of types since there's
> only one type, T, in the template.  I'm guessing you mean
> something else?  Maybe:
>
> template< typename[1] T > class vector;
>
> where typename[1] is a new notation meaning maybe something
> like a metaclass or maybe a type of types?  And maybe
> typename[2] means a type of typename[1]'s?
>
> Could you please provide some more details of how a
> std::vector could be used to solve the OP problem?
>
> -Larry
>
>>
>> On Thursday, 11 October 2018 15:05:37 UTC-4, Andrey Davydov wrote:
>>>
>>> It's often needed to index into template parameter pack, when working
>>> with variadic templates, for instance in implementation of
>>> std::get<size_t> of tuple and variant. I wonder if there is any
>>> proposal to add metafunction
>>> <std::size_t I, typename ...Ts>
>>> using type_pack_element = ...
>>> It can be implemented using existing language facilities or, similarly
>>> to std::make_integer_sequence, using compiler intrinsic. It's already
>>> implemented in Clang (__type_pack_element), and IMO it should not be
>>> hard to support in other compilers. Moreover it should be much more
>>> efficient from compile-time perspective because variadic pack is stored in
>>> some vector-like data structure, and consequently to get element by index
>>> from it is much cheaper than class template instantiation, overload
>>> resolution, etc...
>>>
>> --
> 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/a9f1d81b-bc39-4659-ba14-42a2fa354c3d%40isocpp.org
> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/a9f1d81b-bc39-4659-ba14-42a2fa354c3d%40isocpp.org?utm_medium=email&utm_source=footer>
> .
>

--
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/CAPuuy5eWjTo2yPyfC1NJiFVC8_ae%2B6uVk_eD_jnxsC221ZLhMg%40mail.gmail.com.

--000000000000efd0ad0579b0391a
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"auto">I believe the intent is something like=C2=A0 `std::vector=
&lt;std::type&gt;` where `std::type` is a value representing a type. So, in=
stead of `template &lt;typename... Ts&gt;`, you would store each T as a val=
ue in the vector.</div><br><div class=3D"gmail_quote"><div dir=3D"ltr">On T=
hu, Nov 1, 2018, 10:48 PM  &lt;<a href=3D"mailto:cppljevans@gmail.com">cppl=
jevans@gmail.com</a> wrote:<br></div><blockquote class=3D"gmail_quote" styl=
e=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div di=
r=3D"ltr"><br><br>On Thursday, November 1, 2018 at 5:43:58 PM UTC-5, Louis =
Dionne wrote:<blockquote class=3D"gmail_quote" style=3D"margin:0;margin-lef=
t:0.8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr">Sorry=
 for being late in the game. I originally implemented=C2=A0<span style=3D"f=
ont-family:&quot;courier new&quot;,monospace;font-size:small">__type_pack_e=
lement</span>=C2=A0in Clang as a workaround for the lack of efficient ways =
to index parameter packs in the context of template based metaprogramming. =
At this moment, I do not think that standardizing this facility is a good i=
dea.<div><br></div><div>C++ wants to move away of template-based metaprogra=
mming and into constexpr value metaprogramming. This is a rather long journ=
ey, but the idea is that std::vector should be your type list of the future=
.. In a world like that, indexing a type list can be done with operator[] on=
 the vector, and that should be O(1) compile-time.</div><div><br></div><div=
>Just my .02,</div><div>Louis<br></div></div></blockquote><div>=C2=A0Louis,=
 I don&#39;t see how:<br><br>template &lt; typename T, typename Alloc =3D a=
llocator&lt;T&gt; &gt; class vector; <br><br>could be used to index into a =
pack of types since there&#39;s<br>only one type, T, in the template.=C2=A0=
 I&#39;m guessing you mean<br>something else?=C2=A0 Maybe:<br><br>template&=
lt; typename[1] T &gt; class vector;<br><br>where typename[1] is a new nota=
tion meaning maybe something<br>like a metaclass or maybe a type of types?=
=C2=A0 And maybe<br>typename[2] means a type of typename[1]&#39;s?<br><br>C=
ould you please provide some more details of how a<br>std::vector could be =
used to solve the OP problem?<br><br>-Larry</div><blockquote class=3D"gmail=
_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padd=
ing-left:1ex"><div dir=3D"ltr"><div><br>On Thursday, 11 October 2018 15:05:=
37 UTC-4, Andrey Davydov  wrote:<blockquote class=3D"gmail_quote" style=3D"=
margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex"><di=
v dir=3D"ltr"><span style=3D"font-size:small">It&#39;s often needed to inde=
x into template parameter pack, when working with variadic templates, for i=
nstance in implementation of <font face=3D"courier new, monospace">std::get=
&lt;size_t&gt;</font> of <font face=3D"courier new, monospace">tuple</font>=
 and <font face=3D"courier new, monospace">variant</font>. I wonder if ther=
e is any proposal to add metafunction=C2=A0</span><div style=3D"background-=
color:rgb(250,250,250);border-color:rgb(187,187,187);border-style:solid;bor=
der-width:1px"><code><div><span style=3D"color:#008">&lt;std::size_t</span>=
<span style=3D"color:#000"> </span><span style=3D"color:#606">I</span><span=
 style=3D"color:#000">, </span><span style=3D"color:#606">typename</span><s=
pan style=3D"color:#000"> ...</span><span style=3D"color:#606">Ts</span><sp=
an style=3D"color:#008">&gt;</span><span style=3D"color:#000"><br>using typ=
e_pack_element =3D ...<br></span></div></code></div><div><span style=3D"fon=
t-size:small">It</span><span style=3D"font-size:small">=C2=A0</span><span s=
tyle=3D"font-size:small">can be implemented using existing language facilit=
ies or, similarly to <font face=3D"courier new, monospace">std::make_intege=
r_sequence</font>, using compiler intrinsic. It&#39;s already implemented i=
n Clang (<font face=3D"courier new, monospace">__type_pack_element</font>),=
 and IMO it should not be hard to support in other compilers. Moreover it s=
hould be much more efficient from compile-time perspective because variadic=
 pack is stored in some vector-like data structure, and consequently to get=
 element by index from it is much cheaper than class template instantiation=
, overload resolution, etc...</span></div></div></blockquote></div></div></=
blockquote></div>

<p></p>

-- <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" target=3D"_=
blank" rel=3D"noreferrer">std-proposals+unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank" rel=3D"noreferrer">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/a9f1d81b-bc39-4659-ba14-42a2fa354c3d%=
40isocpp.org?utm_medium=3Demail&amp;utm_source=3Dfooter" target=3D"_blank" =
rel=3D"noreferrer">https://groups.google.com/a/isocpp.org/d/msgid/std-propo=
sals/a9f1d81b-bc39-4659-ba14-42a2fa354c3d%40isocpp.org</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&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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CAPuuy5eWjTo2yPyfC1NJiFVC8_ae%2B6uVk_=
eD_jnxsC221ZLhMg%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">h=
ttps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAPuuy5eWjTo2yP=
yfC1NJiFVC8_ae%2B6uVk_eD_jnxsC221ZLhMg%40mail.gmail.com</a>.<br />

--000000000000efd0ad0579b0391a--

.


Author: Louis Dionne <ldionne.2@gmail.com>
Date: Fri, 2 Nov 2018 11:44:42 -0400
Raw View
--000000000000a7b5900579b06a2c
Content-Type: text/plain; charset="UTF-8"

Apologies for the self promotion, but this talk explains that (and more):
https://www.youtube.com/watch?v=CRDNPwXDVp0&t=1s. It may be worth it if you
are interested by the topic.

Louis


On Fri, Nov 2, 2018 at 11:31 AM Justin Bassett <jbassett271@gmail.com>
wrote:

> I believe the intent is something like  `std::vector<std::type>` where
> `std::type` is a value representing a type. So, instead of `template
> <typename... Ts>`, you would store each T as a value in the vector.
>
> On Thu, Nov 1, 2018, 10:48 PM <cppljevans@gmail.com wrote:
>
>>
>>
>> On Thursday, November 1, 2018 at 5:43:58 PM UTC-5, Louis Dionne wrote:
>>>
>>> Sorry for being late in the game. I originally implemented
>>> __type_pack_element in Clang as a workaround for the lack of efficient
>>> ways to index parameter packs in the context of template based
>>> metaprogramming. At this moment, I do not think that standardizing this
>>> facility is a good idea.
>>>
>>> C++ wants to move away of template-based metaprogramming and into
>>> constexpr value metaprogramming. This is a rather long journey, but the
>>> idea is that std::vector should be your type list of the future. In a world
>>> like that, indexing a type list can be done with operator[] on the vector,
>>> and that should be O(1) compile-time.
>>>
>>> Just my .02,
>>> Louis
>>>
>>  Louis, I don't see how:
>>
>> template < typename T, typename Alloc = allocator<T> > class vector;
>>
>> could be used to index into a pack of types since there's
>> only one type, T, in the template.  I'm guessing you mean
>> something else?  Maybe:
>>
>> template< typename[1] T > class vector;
>>
>> where typename[1] is a new notation meaning maybe something
>> like a metaclass or maybe a type of types?  And maybe
>> typename[2] means a type of typename[1]'s?
>>
>> Could you please provide some more details of how a
>> std::vector could be used to solve the OP problem?
>>
>
>> -Larry
>>
>>>
>>> On Thursday, 11 October 2018 15:05:37 UTC-4, Andrey Davydov wrote:
>>>>
>>>> It's often needed to index into template parameter pack, when working
>>>> with variadic templates, for instance in implementation of
>>>> std::get<size_t> of tuple and variant. I wonder if there is any
>>>> proposal to add metafunction
>>>> <std::size_t I, typename ...Ts>
>>>> using type_pack_element = ...
>>>> It can be implemented using existing language facilities or, similarly
>>>> to std::make_integer_sequence, using compiler intrinsic. It's already
>>>> implemented in Clang (__type_pack_element), and IMO it should not be
>>>> hard to support in other compilers. Moreover it should be much more
>>>> efficient from compile-time perspective because variadic pack is stored in
>>>> some vector-like data structure, and consequently to get element by index
>>>> from it is much cheaper than class template instantiation, overload
>>>> resolution, etc...
>>>>
>>> --
>> 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/a9f1d81b-bc39-4659-ba14-42a2fa354c3d%40isocpp.org
>> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/a9f1d81b-bc39-4659-ba14-42a2fa354c3d%40isocpp.org?utm_medium=email&utm_source=footer>
>> .
>>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "ISO C++ Standard - Future Proposals" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/a/isocpp.org/d/topic/std-proposals/HRx31Xhg7CU/unsubscribe
> .
> To unsubscribe from this group and all its topics, 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/CAPuuy5eWjTo2yPyfC1NJiFVC8_ae%2B6uVk_eD_jnxsC221ZLhMg%40mail.gmail.com
> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAPuuy5eWjTo2yPyfC1NJiFVC8_ae%2B6uVk_eD_jnxsC221ZLhMg%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>

--
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/CAOOKoUqYnyO5kqKR-uKJnKZ-adP-Q5boxScA1GLBL%3DeRaieTbw%40mail.gmail.com.

--000000000000a7b5900579b06a2c
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div dir=3D"ltr"><div class=3D"gmail_default" style=3D"fon=
t-family:arial,helvetica,sans-serif">Apologies for the self promotion, but =
this talk explains that (and more):=C2=A0<a href=3D"https://www.youtube.com=
/watch?v=3DCRDNPwXDVp0&amp;t=3D1s">https://www.youtube.com/watch?v=3DCRDNPw=
XDVp0&amp;t=3D1s</a>. It may be worth it if you are interested by the topic=
..</div><div class=3D"gmail_default" style=3D"font-family:arial,helvetica,sa=
ns-serif"><br></div><div class=3D"gmail_default" style=3D"font-family:arial=
,helvetica,sans-serif">Louis</div><div dir=3D"ltr"><div style=3D"font-famil=
y:arial,helvetica,sans-serif"><br></div><br><div class=3D"gmail_quote"><div=
 dir=3D"ltr">On Fri, Nov 2, 2018 at 11:31 AM Justin Bassett &lt;<a href=3D"=
mailto:jbassett271@gmail.com" target=3D"_blank">jbassett271@gmail.com</a>&g=
t; wrote:<br></div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0p=
x 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color=
:rgb(204,204,204);padding-left:1ex"><div dir=3D"auto">I believe the intent =
is something like=C2=A0 `std::vector&lt;std::type&gt;` where `std::type` is=
 a value representing a type. So, instead of `template &lt;typename... Ts&g=
t;`, you would store each T as a value in the vector.</div><br><div class=
=3D"gmail_quote"><div dir=3D"ltr">On Thu, Nov 1, 2018, 10:48 PM  &lt;<a hre=
f=3D"mailto:cppljevans@gmail.com" target=3D"_blank">cppljevans@gmail.com</a=
> wrote:<br></div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px=
 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:=
rgb(204,204,204);padding-left:1ex"><div dir=3D"ltr"><br><br>On Thursday, No=
vember 1, 2018 at 5:43:58 PM UTC-5, Louis Dionne wrote:<blockquote class=3D=
"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left-width:1px;borde=
r-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><di=
v dir=3D"ltr">Sorry for being late in the game. I originally implemented=C2=
=A0<span style=3D"font-family:&quot;courier new&quot;,monospace;font-size:s=
mall">__type_pack_element</span>=C2=A0in Clang as a workaround for the lack=
 of efficient ways to index parameter packs in the context of template base=
d metaprogramming. At this moment, I do not think that standardizing this f=
acility is a good idea.<div><br></div><div>C++ wants to move away of templa=
te-based metaprogramming and into constexpr value metaprogramming. This is =
a rather long journey, but the idea is that std::vector should be your type=
 list of the future. In a world like that, indexing a type list can be done=
 with operator[] on the vector, and that should be O(1) compile-time.</div>=
<div><br></div><div>Just my .02,</div><div>Louis<br></div></div></blockquot=
e><div>=C2=A0Louis, I don&#39;t see how:<br><br>template &lt; typename T, t=
ypename Alloc =3D allocator&lt;T&gt; &gt; class vector; <br><br>could be us=
ed to index into a pack of types since there&#39;s<br>only one type, T, in =
the template.=C2=A0 I&#39;m guessing you mean<br>something else?=C2=A0 Mayb=
e:<br><br>template&lt; typename[1] T &gt; class vector;<br><br>where typena=
me[1] is a new notation meaning maybe something<br>like a metaclass or mayb=
e a type of types?=C2=A0 And maybe<br>typename[2] means a type of typename[=
1]&#39;s?<br><br>Could you please provide some more details of how a<br>std=
::vector could be used to solve the OP problem?=C2=A0</div></div></blockquo=
te></div></blockquote><blockquote class=3D"gmail_quote" style=3D"margin:0px=
 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-co=
lor:rgb(204,204,204);padding-left:1ex"><div class=3D"gmail_quote"><blockquo=
te class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left-widt=
h:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-le=
ft:1ex"><div dir=3D"ltr"><div><br>-Larry</div><blockquote class=3D"gmail_qu=
ote" style=3D"margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-st=
yle:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir=3D"=
ltr"><div><br>On Thursday, 11 October 2018 15:05:37 UTC-4, Andrey Davydov  =
wrote:<blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;b=
order-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,=
204);padding-left:1ex"><div dir=3D"ltr"><span style=3D"font-size:small">It&=
#39;s often needed to index into template parameter pack, when working with=
 variadic templates, for instance in implementation of <font face=3D"courie=
r new, monospace">std::get&lt;size_t&gt;</font> of <font face=3D"courier ne=
w, monospace">tuple</font> and <font face=3D"courier new, monospace">varian=
t</font>. I wonder if there is any proposal to add metafunction=C2=A0</span=
><div style=3D"background-color:rgb(250,250,250);border:1px solid rgb(187,1=
87,187)"><code><div><span style=3D"color:rgb(0,0,136)">&lt;std::size_t</spa=
n><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(102,0,1=
02)">I</span><span style=3D"color:rgb(0,0,0)">, </span><span style=3D"color=
:rgb(102,0,102)">typename</span><span style=3D"color:rgb(0,0,0)"> ...</span=
><span style=3D"color:rgb(102,0,102)">Ts</span><span style=3D"color:rgb(0,0=
,136)">&gt;</span><span style=3D"color:rgb(0,0,0)"><br>using type_pack_elem=
ent =3D ...<br></span></div></code></div><div><span style=3D"font-size:smal=
l">It</span><span style=3D"font-size:small">=C2=A0</span><span style=3D"fon=
t-size:small">can be implemented using existing language facilities or, sim=
ilarly to <font face=3D"courier new, monospace">std::make_integer_sequence<=
/font>, using compiler intrinsic. It&#39;s already implemented in Clang (<f=
ont face=3D"courier new, monospace">__type_pack_element</font>), and IMO it=
 should not be hard to support in other compilers. Moreover it should be mu=
ch more efficient from compile-time perspective because variadic pack is st=
ored in some vector-like data structure, and consequently to get element by=
 index from it is much cheaper than class template instantiation, overload =
resolution, etc...</span></div></div></blockquote></div></div></blockquote>=
</div>

<p></p>

-- <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" rel=3D"nore=
ferrer" target=3D"_blank">std-proposals+unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" rel=3D"noreferrer" target=3D"_blank">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/a9f1d81b-bc39-4659-ba14-42a2fa354c3d%=
40isocpp.org?utm_medium=3Demail&amp;utm_source=3Dfooter" rel=3D"noreferrer"=
 target=3D"_blank">https://groups.google.com/a/isocpp.org/d/msgid/std-propo=
sals/a9f1d81b-bc39-4659-ba14-42a2fa354c3d%40isocpp.org</a>.<br>
</blockquote></div>

<p></p>

-- <br>
You received this message because you are subscribed to a topic in the Goog=
le Groups &quot;ISO C++ Standard - Future Proposals&quot; group.<br>
To unsubscribe from this topic, visit <a href=3D"https://groups.google.com/=
a/isocpp.org/d/topic/std-proposals/HRx31Xhg7CU/unsubscribe" target=3D"_blan=
k">https://groups.google.com/a/isocpp.org/d/topic/std-proposals/HRx31Xhg7CU=
/unsubscribe</a>.<br>
To unsubscribe from this group and all its topics, send an email to <a href=
=3D"mailto:std-proposals+unsubscribe@isocpp.org" target=3D"_blank">std-prop=
osals+unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">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/CAPuuy5eWjTo2yPyfC1NJiFVC8_ae%2B6uVk_=
eD_jnxsC221ZLhMg%40mail.gmail.com?utm_medium=3Demail&amp;utm_source=3Dfoote=
r" target=3D"_blank">https://groups.google.com/a/isocpp.org/d/msgid/std-pro=
posals/CAPuuy5eWjTo2yPyfC1NJiFVC8_ae%2B6uVk_eD_jnxsC221ZLhMg%40mail.gmail.c=
om</a>.<br>
</blockquote></div></div></div></div>

<p></p>

-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CAOOKoUqYnyO5kqKR-uKJnKZ-adP-Q5boxScA=
1GLBL%3DeRaieTbw%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">h=
ttps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAOOKoUqYnyO5kq=
KR-uKJnKZ-adP-Q5boxScA1GLBL%3DeRaieTbw%40mail.gmail.com</a>.<br />

--000000000000a7b5900579b06a2c--

.


Author: Andrey Davydov <andrey.a.davydov@gmail.com>
Date: Fri, 2 Nov 2018 10:54:34 -0700 (PDT)
Raw View
------=_Part_969_2029429109.1541181274863
Content-Type: multipart/alternative;
 boundary="----=_Part_970_1600027196.1541181274864"

------=_Part_970_1600027196.1541181274864
Content-Type: text/plain; charset="UTF-8"


>
> Sorry for being late in the game. I originally implemented
> __type_pack_element in Clang as a workaround for the lack of efficient
> ways to index parameter packs in the context of template based
> metaprogramming. At this moment, I do not think that standardizing this
> facility is a good idea.
>
> C++ wants to move away of template-based metaprogramming and into
> constexpr value metaprogramming. This is a rather long journey, but the
> idea is that std::vector should be your type list of the future. In a world
> like that, indexing a type list can be done with operator[] on the vector,
> and that should be O(1) compile-time.
>

I believe that even when vector<metatype> will be available (after C++26?),
the following implementation of tuple_element
template<size_t I, typename...Ts>
using type_pack_element = __type_pack_element<I, Ts...>;
will be more efficient than
template<typename...Ts>
constexpr metatype metatypes[] = { $reflect(Ts)... };

template<size_t I, typename...Ts>
using type_pack_element = $unreflect(metatypes<Ts...>[i]);
In any case it is implementation detail and maintainers of standard library
can choose the most efficient way and will change it when reflection will
be supported.

--
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/8d1ce28d-bd58-4374-b056-84ab87284f91%40isocpp.org.

------=_Part_970_1600027196.1541181274864
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><blockquote class=3D"gmail_quote" style=3D"margin: 0;margi=
n-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"l=
tr">Sorry for being late in the game. I originally implemented=C2=A0<span s=
tyle=3D"font-family:&quot;courier new&quot;,monospace;font-size:small">__ty=
pe_pack_<wbr>element</span>=C2=A0in Clang as a workaround for the lack of e=
fficient ways to index parameter packs in the context of template based met=
aprogramming. At this moment, I do not think that standardizing this facili=
ty is a good idea.<div><br></div><div>C++ wants to move away of template-ba=
sed metaprogramming and into constexpr value metaprogramming. This is a rat=
her long journey, but the idea is that std::vector should be your type list=
 of the future. In a world like that, indexing a type list can be done with=
 operator[] on the vector, and that should be O(1) compile-time.</div></div=
></blockquote><div><br></div><div>I believe that even when <font face=3D"co=
urier new, monospace">vector&lt;metatype&gt;</font> will be available (afte=
r C++26?), the following implementation of <font face=3D"courier new, monos=
pace">tuple_element</font></div><div><font face=3D"courier new, monospace">=
<div class=3D"prettyprint" style=3D"background-color: rgb(250, 250, 250); b=
order-color: rgb(187, 187, 187); border-style: solid; border-width: 1px; ov=
erflow-wrap: break-word;"><code class=3D"prettyprint"><div class=3D"subpret=
typrint"><font color=3D"#666600"><span style=3D"color: #008;" class=3D"styl=
ed-by-prettify">template</span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">&lt;</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify">size_t I</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </=
span><span style=3D"color: #008;" class=3D"styled-by-prettify">typename</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">...</span><spa=
n style=3D"color: #606;" class=3D"styled-by-prettify">Ts</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">&gt;</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #=
008;" class=3D"styled-by-prettify">using</span><span style=3D"color: #000;"=
 class=3D"styled-by-prettify"> type_pack_element </span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> __type_pack_element</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">&lt;</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify">I</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> </span><span style=3D"color: #606;" class=3D"styled-by-p=
rettify">Ts</span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>...&gt;;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><=
br></span></font></div></code></div>will be more efficient than<br><div cla=
ss=3D"prettyprint" style=3D"background-color: rgb(250, 250, 250); border-co=
lor: rgb(187, 187, 187); border-style: solid; border-width: 1px; overflow-w=
rap: break-word;"><code class=3D"prettyprint"><div class=3D"subprettyprint"=
><div class=3D"prettyprint" style=3D"border-width: 1px; border-style: solid=
; border-color: rgb(187, 187, 187); font-family: &quot;courier new&quot;, m=
onospace; overflow-wrap: break-word;"><code class=3D"prettyprint"><div clas=
s=3D"subprettyprint"><span class=3D"styled-by-prettify" style=3D"color: rgb=
(0, 0, 136);">template</span><span class=3D"styled-by-prettify" style=3D"co=
lor: rgb(102, 102, 0);">&lt;</span><span class=3D"styled-by-prettify" style=
=3D"color: rgb(0, 0, 136);">typename</span><span class=3D"styled-by-prettif=
y" style=3D"color: rgb(102, 102, 0);">...</span><span class=3D"styled-by-pr=
ettify" style=3D"color: rgb(102, 0, 102);">Ts</span><span class=3D"styled-b=
y-prettify" style=3D"color: rgb(102, 102, 0);">&gt;<br></span><span style=
=3D"color: rgb(0, 0, 0);">constexpr metatype metatypes[] =3D { $reflect(Ts)=
.... };<br></span><font color=3D"#666600"><span class=3D"styled-by-prettify"=
 style=3D"color: rgb(0, 0, 136);"><br>template</span><span class=3D"styled-=
by-prettify">&lt;</span><span class=3D"styled-by-prettify" style=3D"color: =
rgb(0, 0, 0);">size_t I</span><span class=3D"styled-by-prettify">,</span><s=
pan class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);">=C2=A0</spa=
n><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 136);">typen=
ame</span><span class=3D"styled-by-prettify">...</span><span class=3D"style=
d-by-prettify" style=3D"color: rgb(102, 0, 102);">Ts</span><span class=3D"s=
tyled-by-prettify">&gt;</span><span class=3D"styled-by-prettify" style=3D"c=
olor: rgb(0, 0, 0);"><br></span></font><span class=3D"styled-by-prettify" s=
tyle=3D"color: rgb(0, 0, 136);">using</span><span class=3D"styled-by-pretti=
fy" style=3D"color: rgb(0, 0, 0);">=C2=A0type_pack_element=C2=A0</span><spa=
n class=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">=3D</span=
><font color=3D"#666600"><span class=3D"styled-by-prettify" style=3D"color:=
 rgb(0, 0, 0);">=C2=A0</span><span class=3D"styled-by-prettify" style=3D"co=
lor: rgb(0, 0, 0);">$unreflect(metatypes&lt;Ts...&gt;[i])</span><span class=
=3D"styled-by-prettify">;</span></font></div></code></div></div></code></di=
v>In any case it is implementation detail and maintainers of standard libra=
ry can choose the most efficient way and will change it when reflection wil=
l be supported.</font></div></div>

<p></p>

-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/8d1ce28d-bd58-4374-b056-84ab87284f91%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/8d1ce28d-bd58-4374-b056-84ab87284f91=
%40isocpp.org</a>.<br />

------=_Part_970_1600027196.1541181274864--

------=_Part_969_2029429109.1541181274863--

.


Author: Louis Dionne <ldionne.2@gmail.com>
Date: Sat, 3 Nov 2018 13:33:47 -0400
Raw View
--000000000000947e080579c60ed5
Content-Type: text/plain; charset="UTF-8"

On Fri, Nov 2, 2018 at 1:54 PM Andrey Davydov <andrey.a.davydov@gmail.com>
wrote:

> Sorry for being late in the game. I originally implemented
>> __type_pack_element in Clang as a workaround for the lack of efficient
>> ways to index parameter packs in the context of template based
>> metaprogramming. At this moment, I do not think that standardizing this
>> facility is a good idea.
>>
>> C++ wants to move away of template-based metaprogramming and into
>> constexpr value metaprogramming. This is a rather long journey, but the
>> idea is that std::vector should be your type list of the future. In a world
>> like that, indexing a type list can be done with operator[] on the vector,
>> and that should be O(1) compile-time.
>>
>
> I believe that even when vector<metatype> will be available (after
> C++26?), the following implementation of tuple_element
> template<size_t I, typename...Ts>
> using type_pack_element = __type_pack_element<I, Ts...>;
> will be more efficient than
> template<typename...Ts>
> constexpr metatype metatypes[] = { $reflect(Ts)... };
>
> template<size_t I, typename...Ts>
> using type_pack_element = $unreflect(metatypes<Ts...>[i]);
> In any case it is implementation detail and maintainers of standard
> library can choose the most efficient way and will change it when
> reflection will be supported.
>

My point is that in most cases where you would need to index a parameter
pack today, I expect you will instead have a constexpr vector of metatypes
in the future. In that case, directly indexing in that vector is the most
straightforward way of achieving what you want. If what you have is a
parameter pack that you want to index, then yes, using __type_pack_element
would be faster and simpler, but I expect that will be rare when
metaprogramming moves into the constexpr world.

Louis

--
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/CAOOKoUqAADJnVi0N747VPPWF5XFcLBWJN1On9v%3DSq%3D%2B1ipum-A%40mail.gmail.com.

--000000000000947e080579c60ed5
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div class=3D"gmail_default" style=3D"font-family:arial,he=
lvetica,sans-serif"><br></div><br><div class=3D"gmail_quote"><div dir=3D"lt=
r">On Fri, Nov 2, 2018 at 1:54 PM Andrey Davydov &lt;<a href=3D"mailto:andr=
ey.a.davydov@gmail.com">andrey.a.davydov@gmail.com</a>&gt; wrote:<br></div>=
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex"><div dir=3D"ltr"><blockquote class=3D"gmail_=
quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;paddi=
ng-left:1ex"><div dir=3D"ltr">Sorry for being late in the game. I originall=
y implemented=C2=A0<span style=3D"font-family:&quot;courier new&quot;,monos=
pace;font-size:small">__type_pack_element</span>=C2=A0in Clang as a workaro=
und for the lack of efficient ways to index parameter packs in the context =
of template based metaprogramming. At this moment, I do not think that stan=
dardizing this facility is a good idea.<div><br></div><div>C++ wants to mov=
e away of template-based metaprogramming and into constexpr value metaprogr=
amming. This is a rather long journey, but the idea is that std::vector sho=
uld be your type list of the future. In a world like that, indexing a type =
list can be done with operator[] on the vector, and that should be O(1) com=
pile-time.</div></div></blockquote><div><br></div><div>I believe that even =
when <font face=3D"courier new, monospace">vector&lt;metatype&gt;</font> wi=
ll be available (after C++26?), the following implementation of <font face=
=3D"courier new, monospace">tuple_element</font></div><div><font face=3D"co=
urier new, monospace"><div class=3D"m_-5061929689719842995prettyprint" styl=
e=3D"background-color:rgb(250,250,250);border-color:rgb(187,187,187);border=
-style:solid;border-width:1px"><code class=3D"m_-5061929689719842995prettyp=
rint"><div class=3D"m_-5061929689719842995subprettyprint"><font color=3D"#6=
66600"><span style=3D"color:#008" class=3D"m_-5061929689719842995styled-by-=
prettify">template</span><span style=3D"color:#660" class=3D"m_-50619296897=
19842995styled-by-prettify">&lt;</span><span style=3D"color:#000" class=3D"=
m_-5061929689719842995styled-by-prettify">size_t I</span><span style=3D"col=
or:#660" class=3D"m_-5061929689719842995styled-by-prettify">,</span><span s=
tyle=3D"color:#000" class=3D"m_-5061929689719842995styled-by-prettify"> </s=
pan><span style=3D"color:#008" class=3D"m_-5061929689719842995styled-by-pre=
ttify">typename</span><span style=3D"color:#660" class=3D"m_-50619296897198=
42995styled-by-prettify">...</span><span style=3D"color:#606" class=3D"m_-5=
061929689719842995styled-by-prettify">Ts</span><span style=3D"color:#660" c=
lass=3D"m_-5061929689719842995styled-by-prettify">&gt;</span><span style=3D=
"color:#000" class=3D"m_-5061929689719842995styled-by-prettify"><br></span>=
<span style=3D"color:#008" class=3D"m_-5061929689719842995styled-by-prettif=
y">using</span><span style=3D"color:#000" class=3D"m_-5061929689719842995st=
yled-by-prettify"> type_pack_element </span><span style=3D"color:#660" clas=
s=3D"m_-5061929689719842995styled-by-prettify">=3D</span><span style=3D"col=
or:#000" class=3D"m_-5061929689719842995styled-by-prettify"> __type_pack_el=
ement</span><span style=3D"color:#660" class=3D"m_-5061929689719842995style=
d-by-prettify">&lt;</span><span style=3D"color:#000" class=3D"m_-5061929689=
719842995styled-by-prettify">I</span><span style=3D"color:#660" class=3D"m_=
-5061929689719842995styled-by-prettify">,</span><span style=3D"color:#000" =
class=3D"m_-5061929689719842995styled-by-prettify"> </span><span style=3D"c=
olor:#606" class=3D"m_-5061929689719842995styled-by-prettify">Ts</span><spa=
n style=3D"color:#660" class=3D"m_-5061929689719842995styled-by-prettify">.=
...&gt;;</span><span style=3D"color:#000" class=3D"m_-5061929689719842995sty=
led-by-prettify"><br></span></font></div></code></div>will be more efficien=
t than<br><div class=3D"m_-5061929689719842995prettyprint" style=3D"backgro=
und-color:rgb(250,250,250);border-color:rgb(187,187,187);border-style:solid=
;border-width:1px"><code class=3D"m_-5061929689719842995prettyprint"><div c=
lass=3D"m_-5061929689719842995subprettyprint"><div class=3D"m_-506192968971=
9842995prettyprint" style=3D"border-width:1px;border-style:solid;border-col=
or:rgb(187,187,187);font-family:&quot;courier new&quot;,monospace"><code cl=
ass=3D"m_-5061929689719842995prettyprint"><div class=3D"m_-5061929689719842=
995subprettyprint"><span class=3D"m_-5061929689719842995styled-by-prettify"=
 style=3D"color:rgb(0,0,136)">template</span><span class=3D"m_-506192968971=
9842995styled-by-prettify" style=3D"color:rgb(102,102,0)">&lt;</span><span =
class=3D"m_-5061929689719842995styled-by-prettify" style=3D"color:rgb(0,0,1=
36)">typename</span><span class=3D"m_-5061929689719842995styled-by-prettify=
" style=3D"color:rgb(102,102,0)">...</span><span class=3D"m_-50619296897198=
42995styled-by-prettify" style=3D"color:rgb(102,0,102)">Ts</span><span clas=
s=3D"m_-5061929689719842995styled-by-prettify" style=3D"color:rgb(102,102,0=
)">&gt;<br></span><span style=3D"color:rgb(0,0,0)">constexpr metatype metat=
ypes[] =3D { $reflect(Ts)... };<br></span><font color=3D"#666600"><span cla=
ss=3D"m_-5061929689719842995styled-by-prettify" style=3D"color:rgb(0,0,136)=
"><br>template</span><span class=3D"m_-5061929689719842995styled-by-prettif=
y">&lt;</span><span class=3D"m_-5061929689719842995styled-by-prettify" styl=
e=3D"color:rgb(0,0,0)">size_t I</span><span class=3D"m_-5061929689719842995=
styled-by-prettify">,</span><span class=3D"m_-5061929689719842995styled-by-=
prettify" style=3D"color:rgb(0,0,0)">=C2=A0</span><span class=3D"m_-5061929=
689719842995styled-by-prettify" style=3D"color:rgb(0,0,136)">typename</span=
><span class=3D"m_-5061929689719842995styled-by-prettify">...</span><span c=
lass=3D"m_-5061929689719842995styled-by-prettify" style=3D"color:rgb(102,0,=
102)">Ts</span><span class=3D"m_-5061929689719842995styled-by-prettify">&gt=
;</span><span class=3D"m_-5061929689719842995styled-by-prettify" style=3D"c=
olor:rgb(0,0,0)"><br></span></font><span class=3D"m_-5061929689719842995sty=
led-by-prettify" style=3D"color:rgb(0,0,136)">using</span><span class=3D"m_=
-5061929689719842995styled-by-prettify" style=3D"color:rgb(0,0,0)">=C2=A0ty=
pe_pack_element=C2=A0</span><span class=3D"m_-5061929689719842995styled-by-=
prettify" style=3D"color:rgb(102,102,0)">=3D</span><font color=3D"#666600">=
<span class=3D"m_-5061929689719842995styled-by-prettify" style=3D"color:rgb=
(0,0,0)">=C2=A0</span><span class=3D"m_-5061929689719842995styled-by-pretti=
fy" style=3D"color:rgb(0,0,0)">$unreflect(metatypes&lt;Ts...&gt;[i])</span>=
<span class=3D"m_-5061929689719842995styled-by-prettify">;</span></font></d=
iv></code></div></div></code></div>In any case it is implementation detail =
and maintainers of standard library can choose the most efficient way and w=
ill change it when reflection will be supported.</font></div></div></blockq=
uote><div><br></div><div><div class=3D"gmail_default" style=3D"font-family:=
arial,helvetica,sans-serif">My point is that in most cases where you would =
need to index a parameter pack today, I expect you will instead have a cons=
texpr vector of metatypes in the future. In that case, directly indexing in=
 that vector is the most straightforward way of achieving what you want. If=
 what you have is a parameter pack that you want to index, then yes, using =
__type_pack_element would be faster and simpler, but I expect that will be =
rare when metaprogramming moves into the constexpr world.</div></div><div c=
lass=3D"gmail_default" style=3D"font-family:arial,helvetica,sans-serif"><br=
></div><div class=3D"gmail_default" style=3D"font-family:arial,helvetica,sa=
ns-serif">Louis</div><div>=C2=A0</div></div></div>

<p></p>

-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CAOOKoUqAADJnVi0N747VPPWF5XFcLBWJN1On=
9v%3DSq%3D%2B1ipum-A%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfoote=
r">https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAOOKoUqAAD=
JnVi0N747VPPWF5XFcLBWJN1On9v%3DSq%3D%2B1ipum-A%40mail.gmail.com</a>.<br />

--000000000000947e080579c60ed5--

.