Topic: Dynamically-generated member names
Author: flarn2006@gmail.com
Date: Thu, 23 Apr 2015 20:56:40 -0700 (PDT)
Raw View
------=_Part_494_400164702.1429847800037
Content-Type: multipart/alternative;
boundary="----=_Part_495_1796847757.1429847800037"
------=_Part_495_1796847757.1429847800037
Content-Type: text/plain; charset=UTF-8
Basically, my idea is about giving members names that depend on numeric
template parameters. An example, using (obviously) non-standardized syntax
(as such it won't compile) to show how it might be done:
#include <iostream>
template <int n>
struct Example
{
int value using ("value_of_" + n);
Example(int myValue)
{
value = myValue;
}
}
int main(int argc, char *argv[])
{
Example<42> ex;
std::cout << ex.value_of_42 << std::endl; //prints 42
return 0;
}
First off, I know this particular example wouldn't be very useful in
practice. But it's useful as an example. Notice the nonstandard use of the
using keyword. This keyword works very well here, reading as "Declare int
value, using a name determined by ("value_of_" + n)."
The word value here is just the name of the variable used within the class,
which isn't visible outside the class. This is necessary because within the
class the value of n could be anything, meaning the external name could
also be one of many different things.
This could basically be used for having a class with any number of members
determined by template parameters, which as of now (AFAIK) is not possible.
One potential use this would have is making tuples look cleaner. Instead of
using std::get<2>(aTuple), you could use something like aTuple.value2.
A slightly more complex example making use of inheritance to create
multiple members with dynamic names:
#include <iostream>
template <int MaxValue>
struct ListOfValues : public ListOfValues<MaxValue - 1>
{
const int value using ("value_of_" + MaxValue) = MaxValue;
}
template <>
struct ListOfValues<0>
{
const int value_of_0 = 0;
}
int main(int argc, char *argv[])
{
ListOfValues<3> list;
std::cout << list.value_of_0 << list.value_of_1 << list.value_of_2 <<
list.value_of_3 << std::endl; //prints 0123
return 0;
}
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
------=_Part_495_1796847757.1429847800037
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Basically, my idea is about giving members names that depe=
nd on numeric template parameters. An example, using (obviously) non-standa=
rdized syntax (as such it won't compile) to show how it might be done:<br><=
br><div class=3D"prettyprint" style=3D"background-color: rgb(250, 250, 250)=
; border-color: rgb(187, 187, 187); border-style: solid; border-width: 1px;=
word-wrap: break-word;"><code class=3D"prettyprint"><div class=3D"subprett=
yprint"><span style=3D"color: #800;" class=3D"styled-by-prettify">#include<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><sp=
an style=3D"color: #080;" class=3D"styled-by-prettify"><iostream></sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br></span=
><span style=3D"color: #008;" class=3D"styled-by-prettify">template</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify"><</span><span style=3D"c=
olor: #008;" class=3D"styled-by-prettify">int</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"> n</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">></span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"><br></span><span style=3D"color: #008;" class=3D"style=
d-by-prettify">struct</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"> </span><span style=3D"color: #606;" class=3D"styled-by-prettify=
">Example</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><=
br></span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>  =
; </span><span style=3D"color: #008;" class=3D"styled-by-prettify">int</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> value </span><=
span style=3D"color: #008;" class=3D"styled-by-prettify">using</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: #0=
80;" class=3D"styled-by-prettify">"value_of_"</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">+</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> n</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">);</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
><br><br> </span><span style=3D"color: #606;" class=3D"styled-=
by-prettify">Example</span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">(</span><span style=3D"color: #008;" class=3D"styled-by-prettify"=
>int</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> myVal=
ue</span><span style=3D"color: #660;" class=3D"styled-by-prettify">)</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"><br> =
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"><br> =
value </span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> myValue</span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbs=
p; </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
}</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">}</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"><br><br></span><span sty=
le=3D"color: #008;" class=3D"styled-by-prettify">int</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> main</span><span style=3D"color:=
#660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #008;" c=
lass=3D"styled-by-prettify">int</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"> argc</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">ch=
ar</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">*</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify">argv</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">[])</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #660;"=
class=3D"styled-by-prettify">{</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"><br> </span><span style=3D"color: #606;" =
class=3D"styled-by-prettify">Example</span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify"><</span><span style=3D"color: #066;" class=3D"=
styled-by-prettify">42</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">></span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> ex</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br> =
std</span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>::</span><span style=3D"color: #000;" class=3D"styled-by-prettify">cout </=
span><span style=3D"color: #660;" class=3D"styled-by-prettify"><<</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"> ex</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">.</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">value_of_42 </span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify"><<</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> std</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">::</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify">endl</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: #800;" class=3D"styled-by-p=
rettify">//prints 42</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"><br> </span><span style=3D"color: #008;" class=3D"st=
yled-by-prettify">return</span><span style=3D"color: #000;" class=3D"styled=
-by-prettify"> </span><span style=3D"color: #066;" class=3D"styled-by-prett=
ify">0</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</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></span></div></code></di=
v><br>First off, I know this particular example wouldn't be very useful in =
practice. But it's useful as an example. Notice the nonstandard use of the =
<span style=3D"font-family: courier new,monospace;">using</span> keyword. T=
his keyword works very well here, reading as "Declare <span style=3D"font-f=
amily: courier new,monospace;">int value</span>, <span style=3D"font-family=
: courier new,monospace;">using</span> a name determined by <span style=3D"=
font-family: courier new,monospace;">("value_of_" + n)</span>."<br><br>The =
word <span style=3D"font-family: courier new,monospace;">value</span> here =
is just the name of the variable used within the class, which isn't visible=
outside the class. This is necessary because within the class the value of=
<span style=3D"font-family: courier new,monospace;">n</span> could be anyt=
hing, meaning the external name could also be one of many different things.=
<br><br>This could basically be used for having a class with any number of =
members determined by template parameters, which as of now (AFAIK) is not p=
ossible. One potential use this would have is making tuples look cleaner. I=
nstead of using <span style=3D"font-family: courier new,monospace;">std::ge=
t<2>(aTuple)</span>, you could use something like <span style=3D"font=
-family: courier new,monospace;">aTuple.value2</span>.<br><br>A slightly mo=
re complex example making use of inheritance to create multiple members wit=
h dynamic names:<br><br><div class=3D"prettyprint" style=3D"background-colo=
r: rgb(250, 250, 250); border-color: rgb(187, 187, 187); border-style: soli=
d; border-width: 1px; word-wrap: break-word;"><code class=3D"prettyprint"><=
div class=3D"subprettyprint"><span style=3D"color: #800;" class=3D"styled-b=
y-prettify">#include</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"> </span><span style=3D"color: #080;" class=3D"styled-by-prettify"=
><iostream></span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"><br> <br></span><span style=3D"color: #008;" class=3D"styled-by=
-prettify">template</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
<</span><span style=3D"color: #008;" class=3D"styled-by-prettify">int</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span=
style=3D"color: #606;" class=3D"styled-by-prettify">MaxValue</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">></span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"co=
lor: #008;" class=3D"styled-by-prettify">struct</span><span style=3D"color:=
#000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #606;" c=
lass=3D"styled-by-prettify">ListOfValues</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"styled-b=
y-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettif=
y">public</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
</span><span style=3D"color: #606;" class=3D"styled-by-prettify">ListOfValu=
es</span><span style=3D"color: #660;" class=3D"styled-by-prettify"><</sp=
an><span style=3D"color: #606;" class=3D"styled-by-prettify">MaxValue</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">-</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #066=
;" class=3D"styled-by-prettify">1</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">></span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"><br></span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">{</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"><br> </span><span style=3D"color: #008;" class=3D"styled-by=
-prettify">const</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">int=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> value </s=
pan><span style=3D"color: #008;" class=3D"styled-by-prettify">using</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"colo=
r: #080;" class=3D"styled-by-prettify">"value_of_"</span><span style=3D"col=
or: #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"styled-by-prettify"> </span><span style=3D"color: #606;" class=3D"style=
d-by-prettify">MaxValue</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">)</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><spa=
n style=3D"color: #606;" class=3D"styled-by-prettify">MaxValue</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"color:=
#660;" class=3D"styled-by-prettify">}</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"><br> <br></span><span style=3D"color: #008=
;" class=3D"styled-by-prettify">template</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"s=
tyled-by-prettify"><br></span><span style=3D"color: #008;" class=3D"styled-=
by-prettify">struct</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> </span><span style=3D"color: #606;" class=3D"styled-by-prettify">=
ListOfValues</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
"><</span><span style=3D"color: #066;" class=3D"styled-by-prettify">0</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">></span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"><br> </span><span sty=
le=3D"color: #008;" class=3D"styled-by-prettify">const</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #=
008;" class=3D"styled-by-prettify">int</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"> value_of_0 </span><span style=3D"color: #660;"=
class=3D"styled-by-prettify">=3D</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #066;" class=3D"style=
d-by-prettify">0</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br=
></span><span style=3D"color: #660;" class=3D"styled-by-prettify">}</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"><br> <br></sp=
an><span style=3D"color: #008;" class=3D"styled-by-prettify">int</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> main</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"col=
or: #008;" class=3D"styled-by-prettify">int</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"> argc</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-=
prettify">char</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">*</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify">argv</span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">[])</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">{</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"><br> </span><span style=3D"co=
lor: #606;" class=3D"styled-by-prettify">ListOfValues</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify"><</span><span style=3D"color:=
#066;" class=3D"styled-by-prettify">3</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">></span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> list</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">;</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"><br> std</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">::</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify">cout </span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify"><<</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> list</span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>.</span><span style=3D"color: #000;" class=3D"styled-by-prettify">value_of=
_0 </span><span style=3D"color: #660;" class=3D"styled-by-prettify"><<=
;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> list</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">.</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify">value_of_1 </span><span=
style=3D"color: #660;" class=3D"styled-by-prettify"><<</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"> list</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">.</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify">value_of_2 </span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify"><<</span><span style=3D"color:=
#000;" class=3D"styled-by-prettify"> list</span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">.</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify">value_of_3 </span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify"><<</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> std</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">::</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify">endl</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an><span style=3D"color: #800;" class=3D"styled-by-prettify">//prints 0123<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br> =
</span><span style=3D"color: #008;" class=3D"styled-by-prettify">ret=
urn</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span style=3D"color: #066;" class=3D"styled-by-prettify">0</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">}</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"><br></span></div></code></div></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_495_1796847757.1429847800037--
------=_Part_494_400164702.1429847800037--
.
Author: David Krauss <potswa@gmail.com>
Date: Fri, 24 Apr 2015 12:05:43 +0800
Raw View
--Apple-Mail=_7EFFC48B-98F0-410B-88D0-A6D02E916143
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=UTF-8
> On 2015=E2=80=9304=E2=80=9324, at 11:56 AM, flarn2006@gmail.com wrote:
>=20
> This could basically be used for having a class with any number of member=
s determined by template parameters, which as of now (AFAIK) is not possibl=
e. One potential use this would have is making tuples look cleaner. Instead=
of using std::get<2>(aTuple), you could use something like aTuple.value2.
It=E2=80=99s already possible to have aTuple.value<2>(), is the difference =
really worth it?
template< typename tuple >
struct memberwise_tuple : tuple {
using tuple::tuple;
template< std::size_t index >
decltype(auto) value & { return std::get< index >( static_cast< tuple &=
>( * this ) ); }
template< std::size_t index >
decltype(auto) value const & { return std::get< index >( static_cast< t=
uple const & >( * this ) ); }
template< std::size_t index >
decltype(auto) value && { return std::get< index >( static_cast< tuple =
&& >( * this ) ); }
};
--=20
---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
--Apple-Mail=_7EFFC48B-98F0-410B-88D0-A6D02E916143
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=UTF-8
<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html charset=
=3Dutf-8"></head><body style=3D"word-wrap: break-word; -webkit-nbsp-mode: s=
pace; -webkit-line-break: after-white-space;" class=3D""><br class=3D""><di=
v><blockquote type=3D"cite" class=3D""><div class=3D"">On 2015=E2=80=9304=
=E2=80=9324, at 11:56 AM, <a href=3D"mailto:flarn2006@gmail.com" class=3D""=
>flarn2006@gmail.com</a> wrote:</div><br class=3D"Apple-interchange-newline=
"><div class=3D""><span style=3D"font-family: Helvetica; font-size: 12px; f=
ont-style: normal; font-variant: normal; font-weight: normal; letter-spacin=
g: normal; line-height: normal; orphans: auto; text-align: start; text-inde=
nt: 0px; text-transform: none; white-space: normal; widows: auto; word-spac=
ing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !imp=
ortant;" class=3D"">This could basically be used for having a class with an=
y number of members determined by template parameters, which as of now (AFA=
IK) is not possible. One potential use this would have is making tuples loo=
k cleaner. Instead of using<span class=3D"Apple-converted-space"> </sp=
an></span><span style=3D"font-size: 12px; font-style: normal; font-variant:=
normal; font-weight: normal; letter-spacing: normal; line-height: normal; =
orphans: auto; text-align: start; text-indent: 0px; text-transform: none; w=
hite-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-wi=
dth: 0px; font-family: 'courier new', monospace;" class=3D"">std::get<2&=
gt;(aTuple)</span><span style=3D"font-family: Helvetica; font-size: 12px; f=
ont-style: normal; font-variant: normal; font-weight: normal; letter-spacin=
g: normal; line-height: normal; orphans: auto; text-align: start; text-inde=
nt: 0px; text-transform: none; white-space: normal; widows: auto; word-spac=
ing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !imp=
ortant;" class=3D"">, you could use something like<span class=3D"Apple-conv=
erted-space"> </span></span><span style=3D"font-size: 12px; font-style=
: normal; font-variant: normal; font-weight: normal; letter-spacing: normal=
; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; =
text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;=
-webkit-text-stroke-width: 0px; font-family: 'courier new', monospace;" cl=
ass=3D"">aTuple.value2</span><span style=3D"font-family: Helvetica; font-si=
ze: 12px; font-style: normal; font-variant: normal; font-weight: normal; le=
tter-spacing: normal; line-height: normal; orphans: auto; text-align: start=
; text-indent: 0px; text-transform: none; white-space: normal; widows: auto=
; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: =
inline !important;" class=3D"">.</span><br style=3D"font-family: Helvetica;=
font-size: 12px; font-style: normal; font-variant: normal; font-weight: no=
rmal; letter-spacing: normal; line-height: normal; orphans: auto; text-alig=
n: start; text-indent: 0px; text-transform: none; white-space: normal; wido=
ws: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=3D""></=
div></blockquote></div><br class=3D""><div class=3D"">It=E2=80=99s already =
possible to have <font face=3D"Courier" class=3D"">aTuple.value<2>()<=
/font>, is the difference really worth it?</div><div class=3D""><br class=
=3D""></div><div class=3D""><font face=3D"Courier" class=3D"">template< =
typename tuple ></font></div><div class=3D""><font face=3D"Courier" clas=
s=3D"">struct memberwise_tuple : tuple {</font></div><div class=3D""><font =
face=3D"Courier" class=3D""> using tuple::tuple;</font></div><=
div class=3D""><font face=3D"Courier" class=3D""><br class=3D""></font></di=
v><div class=3D""><font face=3D"Courier" class=3D""> template&=
lt; std::size_t index ></font></div><div class=3D""><font face=3D"Courie=
r" class=3D""> decltype(auto) value & { return std::get<=
; index >( static_cast< tuple & >( * this ) ); }</font></div><=
div class=3D""><font face=3D"Courier" class=3D""><br class=3D""></font></di=
v><div class=3D""><font face=3D"Courier" class=3D""> template&=
lt; std::size_t index ></font></div><div class=3D""><font face=3D"Courie=
r" class=3D""> decltype(auto) value const & { return std::=
get< index >( static_cast< tuple const & >( * this ) ); }</=
font></div><div class=3D""><font face=3D"Courier" class=3D""><br class=3D""=
></font></div><div class=3D""><font face=3D"Courier" class=3D""> &nbs=
p; template< std::size_t index ></font></div><div class=3D""><font fa=
ce=3D"Courier" class=3D""> decltype(auto) value && { r=
eturn std::get< index >( static_cast< tuple && >( * thi=
s ) ); }</font></div><div class=3D""><font face=3D"Courier" class=3D"">};</=
font></div></body></html>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
--Apple-Mail=_7EFFC48B-98F0-410B-88D0-A6D02E916143--
.
Author: flarn2006@gmail.com
Date: Wed, 29 Apr 2015 23:18:24 -0700 (PDT)
Raw View
------=_Part_7912_1016127668.1430374704527
Content-Type: multipart/alternative;
boundary="----=_Part_7913_1267755132.1430374704527"
------=_Part_7913_1267755132.1430374704527
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
That's true, I guess that does work just as well.
On Friday, April 24, 2015 at 12:05:55 AM UTC-4, David Krauss wrote:
>
>
> On 2015=E2=80=9304=E2=80=9324, at 11:56 AM, flar...@gmail.com <javascript=
:> wrote:
>
> This could basically be used for having a class with any number of member=
s=20
> determined by template parameters, which as of now (AFAIK) is not possibl=
e.=20
> One potential use this would have is making tuples look cleaner. Instead =
of=20
> using std::get<2>(aTuple), you could use something like aTuple.value2.
>
>
> It=E2=80=99s already possible to have aTuple.value<2>(), is the differenc=
e really=20
> worth it?
>
> template< typename tuple >
> struct memberwise_tuple : tuple {
> using tuple::tuple;
>
> template< std::size_t index >
> decltype(auto) value & { return std::get< index >( static_cast< tuple=
=20
> & >( * this ) ); }
>
> template< std::size_t index >
> decltype(auto) value const & { return std::get< index >( static_cast<=
=20
> tuple const & >( * this ) ); }
>
> template< std::size_t index >
> decltype(auto) value && { return std::get< index >( static_cast< tupl=
e=20
> && >( * this ) ); }
> };
>
--=20
---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
------=_Part_7913_1267755132.1430374704527
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">That's true, I guess that does work just as well.<br><br>O=
n Friday, April 24, 2015 at 12:05:55 AM UTC-4, David Krauss wrote:<blockquo=
te class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left:=
1px #ccc solid;padding-left: 1ex;"><div style=3D"word-wrap:break-word"><br=
><div><blockquote type=3D"cite"><div>On 2015=E2=80=9304=E2=80=9324, at 11:5=
6 AM, <a href=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"O2=
OGAZ8UKjsJ" rel=3D"nofollow" onmousedown=3D"this.href=3D'javascript:';retur=
n true;" onclick=3D"this.href=3D'javascript:';return true;">flar...@gmail.c=
om</a> wrote:</div><br><div><span style=3D"font-family:Helvetica;font-size:=
12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacin=
g:normal;line-height:normal;text-align:start;text-indent:0px;text-transform=
:none;white-space:normal;word-spacing:0px;float:none;display:inline!importa=
nt">This could basically be used for having a class with any number of memb=
ers determined by template parameters, which as of now (AFAIK) is not possi=
ble. One potential use this would have is making tuples look cleaner. Inste=
ad of using<span> </span></span><span style=3D"font-size:12px;font-sty=
le:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line=
-height:normal;text-align:start;text-indent:0px;text-transform:none;white-s=
pace:normal;word-spacing:0px;font-family:'courier new',monospace">std::get&=
lt;2>(aTuple)</span><span style=3D"font-family:Helvetica;font-size:12px;=
font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:nor=
mal;line-height:normal;text-align:start;text-indent:0px;text-transform:none=
;white-space:normal;word-spacing:0px;float:none;display:inline!important">,=
you could use something like<span> </span></span><span style=3D"font-=
size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-s=
pacing:normal;line-height:normal;text-align:start;text-indent:0px;text-tran=
sform:none;white-space:normal;word-spacing:0px;font-family:'courier new',mo=
nospace">aTuple.value2</span><span style=3D"font-family:Helvetica;font-size=
:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spaci=
ng:normal;line-height:normal;text-align:start;text-indent:0px;text-transfor=
m:none;white-space:normal;word-spacing:0px;float:none;display:inline!import=
ant">.</span><br style=3D"font-family:Helvetica;font-size:12px;font-style:n=
ormal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-hei=
ght:normal;text-align:start;text-indent:0px;text-transform:none;white-space=
:normal;word-spacing:0px"></div></blockquote></div><br><div>It=E2=80=99s al=
ready possible to have <font face=3D"Courier">aTuple.value<2>()</font=
>, is the difference really worth it?</div><div><br></div><div><font face=
=3D"Courier">template< typename tuple ></font></div><div><font face=
=3D"Courier">struct memberwise_tuple : tuple {</font></div><div><font face=
=3D"Courier"> using tuple::tuple;</font></div><div><font face=
=3D"Courier"><br></font></div><div><font face=3D"Courier"> tem=
plate< std::size_t index ></font></div><div><font face=3D"Courier">&n=
bsp; decltype(auto) value & { return std::get< index >( st=
atic_cast< tuple & >( * this ) ); }</font></div><div><font face=
=3D"Courier"><br></font></div><div><font face=3D"Courier"> tem=
plate< std::size_t index ></font></div><div><font face=3D"Courier">&n=
bsp; decltype(auto) value const & { return std::get< index &g=
t;( static_cast< tuple const & >( * this ) ); }</font></div><div>=
<font face=3D"Courier"><br></font></div><div><font face=3D"Courier"> =
template< std::size_t index ></font></div><div><font face=3D"C=
ourier"> decltype(auto) value && { return std::get<=
index >( static_cast< tuple && >( * this ) ); }</font></d=
iv><div><font face=3D"Courier">};</font></div></div></blockquote></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_7913_1267755132.1430374704527--
------=_Part_7912_1016127668.1430374704527--
.
Author: =?UTF-8?Q?Klaim_=2D_Jo=C3=ABl_Lamotte?= <mjklaim@gmail.com>
Date: Tue, 5 May 2015 19:25:59 +0200
Raw View
--047d7bf0c1b4d7b5f6051558f8ea
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
If my understanding is correct, this example does not work if two members
have the same type.
On Fri, Apr 24, 2015 at 6:05 AM, David Krauss <potswa@gmail.com> wrote:
>
> On 2015=E2=80=9304=E2=80=9324, at 11:56 AM, flarn2006@gmail.com wrote:
>
> This could basically be used for having a class with any number of member=
s
> determined by template parameters, which as of now (AFAIK) is not possibl=
e.
> One potential use this would have is making tuples look cleaner. Instead =
of
> using std::get<2>(aTuple), you could use something like aTuple.value2.
>
>
> It=E2=80=99s already possible to have aTuple.value<2>(), is the differenc=
e really
> worth it?
>
> template< typename tuple >
> struct memberwise_tuple : tuple {
> using tuple::tuple;
>
> template< std::size_t index >
> decltype(auto) value & { return std::get< index >( static_cast< tuple
> & >( * this ) ); }
>
> template< std::size_t index >
> decltype(auto) value const & { return std::get< index >( static_cast<
> tuple const & >( * this ) ); }
>
> template< std::size_t index >
> decltype(auto) value && { return std::get< index >( static_cast< tupl=
e
> && >( * this ) ); }
> };
>
> --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "ISO C++ Standard - Future Proposals" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to std-proposals+unsubscribe@isocpp.org.
> To post to this group, send email to std-proposals@isocpp.org.
> Visit this group at
> http://groups.google.com/a/isocpp.org/group/std-proposals/.
>
--=20
---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
--047d7bf0c1b4d7b5f6051558f8ea
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">If my understanding is correct, this example does not work=
if two members have the same type.</div><div class=3D"gmail_extra"><br><di=
v class=3D"gmail_quote">On Fri, Apr 24, 2015 at 6:05 AM, David Krauss <span=
dir=3D"ltr"><<a href=3D"mailto:potswa@gmail.com" target=3D"_blank">pots=
wa@gmail.com</a>></span> wrote:<br><blockquote class=3D"gmail_quote" sty=
le=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div s=
tyle=3D"word-wrap:break-word"><span class=3D""><br><div><blockquote type=3D=
"cite"><div>On 2015=E2=80=9304=E2=80=9324, at 11:56 AM, <a href=3D"mailto:f=
larn2006@gmail.com" target=3D"_blank">flarn2006@gmail.com</a> wrote:</div><=
br><div><span style=3D"font-family:Helvetica;font-size:12px;font-style:norm=
al;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height=
:normal;text-align:start;text-indent:0px;text-transform:none;white-space:no=
rmal;word-spacing:0px;float:none;display:inline!important">This could basic=
ally be used for having a class with any number of members determined by te=
mplate parameters, which as of now (AFAIK) is not possible. One potential u=
se this would have is making tuples look cleaner. Instead of using<span>=C2=
=A0</span></span><span style=3D"font-size:12px;font-style:normal;font-varia=
nt:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-=
align:start;text-indent:0px;text-transform:none;white-space:normal;word-spa=
cing:0px;font-family:'courier new',monospace">std::get<2>(aTu=
ple)</span><span style=3D"font-family:Helvetica;font-size:12px;font-style:n=
ormal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-hei=
ght:normal;text-align:start;text-indent:0px;text-transform:none;white-space=
:normal;word-spacing:0px;float:none;display:inline!important">, you could u=
se something like<span>=C2=A0</span></span><span style=3D"font-size:12px;fo=
nt-style:normal;font-variant:normal;font-weight:normal;letter-spacing:norma=
l;line-height:normal;text-align:start;text-indent:0px;text-transform:none;w=
hite-space:normal;word-spacing:0px;font-family:'courier new',monosp=
ace">aTuple.value2</span><span style=3D"font-family:Helvetica;font-size:12p=
x;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:n=
ormal;line-height:normal;text-align:start;text-indent:0px;text-transform:no=
ne;white-space:normal;word-spacing:0px;float:none;display:inline!important"=
>.</span><br style=3D"font-family:Helvetica;font-size:12px;font-style:norma=
l;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:=
normal;text-align:start;text-indent:0px;text-transform:none;white-space:nor=
mal;word-spacing:0px"></div></blockquote></div><br></span><div>It=E2=80=99s=
already possible to have <font face=3D"Courier">aTuple.value<2>()</f=
ont>, is the difference really worth it?</div><div><br></div><div><font fac=
e=3D"Courier">template< typename tuple ></font></div><div><font face=
=3D"Courier">struct memberwise_tuple : tuple {</font></div><div><font face=
=3D"Courier">=C2=A0 =C2=A0 using tuple::tuple;</font></div><div><font face=
=3D"Courier"><br></font></div><div><font face=3D"Courier">=C2=A0 =C2=A0 tem=
plate< std::size_t index ></font></div><div><font face=3D"Courier">=
=C2=A0 =C2=A0 decltype(auto) value & { return std::get< index >( =
static_cast< tuple & >( * this ) ); }</font></div><div><font face=
=3D"Courier"><br></font></div><div><font face=3D"Courier">=C2=A0 =C2=A0 tem=
plate< std::size_t index ></font></div><div><font face=3D"Courier">=
=C2=A0 =C2=A0 decltype(auto) value const & { return std::get< index =
>( static_cast< tuple const & >( * this ) ); }</font></div><di=
v><font face=3D"Courier"><br></font></div><div><font face=3D"Courier">=C2=
=A0 =C2=A0 template< std::size_t index ></font></div><div><font face=
=3D"Courier">=C2=A0 =C2=A0 decltype(auto) value && { return std::ge=
t< index >( static_cast< tuple && >( * this ) ); }</fon=
t></div><div><font face=3D"Courier">};</font></div></div><div class=3D"HOEn=
Zb"><div class=3D"h5">
<p></p>
-- <br>
<br>
--- <br>
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org" 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" target=3D"_blank">std-proposals@isocpp.org</a>.<br>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" target=3D"_blank">http://groups.google.com/a/isocpp.org/gro=
up/std-proposals/</a>.<br>
</div></div></blockquote></div><br></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
--047d7bf0c1b4d7b5f6051558f8ea--
.
Author: =?UTF-8?Q?David_Rodr=C3=ADguez_Ibeas?= <dibeas@ieee.org>
Date: Wed, 6 May 2015 11:58:36 +0100
Raw View
--089e012299d44601e6051567adb9
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
How so? The type is inferred from the result of a call to 'std::get<N>'
with the *index*, not the type.
David
On Tue, May 5, 2015 at 6:25 PM, Klaim - Jo=C3=ABl Lamotte <mjklaim@gmail.co=
m>
wrote:
> If my understanding is correct, this example does not work if two members
> have the same type.
>
> On Fri, Apr 24, 2015 at 6:05 AM, David Krauss <potswa@gmail.com> wrote:
>
>>
>> On 2015=E2=80=9304=E2=80=9324, at 11:56 AM, flarn2006@gmail.com wrote:
>>
>> This could basically be used for having a class with any number of
>> members determined by template parameters, which as of now (AFAIK) is no=
t
>> possible. One potential use this would have is making tuples look cleane=
r.
>> Instead of using std::get<2>(aTuple), you could use something like
>> aTuple.value2.
>>
>>
>> It=E2=80=99s already possible to have aTuple.value<2>(), is the differen=
ce
>> really worth it?
>>
>> template< typename tuple >
>> struct memberwise_tuple : tuple {
>> using tuple::tuple;
>>
>> template< std::size_t index >
>> decltype(auto) value & { return std::get< index >( static_cast< tupl=
e
>> & >( * this ) ); }
>>
>> template< std::size_t index >
>> decltype(auto) value const & { return std::get< index >( static_cast=
<
>> tuple const & >( * this ) ); }
>>
>> template< std::size_t index >
>> decltype(auto) value && { return std::get< index >( static_cast<
>> tuple && >( * this ) ); }
>> };
>>
>> --
>>
>> ---
>> You received this message because you are subscribed to the Google Group=
s
>> "ISO C++ Standard - Future Proposals" group.
>> To unsubscribe from this group and stop receiving emails from it, send a=
n
>> email to std-proposals+unsubscribe@isocpp.org.
>> To post to this group, send email to std-proposals@isocpp.org.
>> Visit this group at
>> http://groups.google.com/a/isocpp.org/group/std-proposals/.
>>
>
> --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "ISO C++ Standard - Future Proposals" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to std-proposals+unsubscribe@isocpp.org.
> To post to this group, send email to std-proposals@isocpp.org.
> Visit this group at
> http://groups.google.com/a/isocpp.org/group/std-proposals/.
>
--=20
---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
--089e012299d44601e6051567adb9
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">How so? The type is inferred from the result of a call to =
'std::get<N>' with the *index*, not the type.<br><br>=C2=A0 =
=C2=A0 David<br><div class=3D"gmail_extra"><br><div class=3D"gmail_quote">O=
n Tue, May 5, 2015 at 6:25 PM, Klaim - Jo=C3=ABl Lamotte <span dir=3D"ltr">=
<<a href=3D"mailto:mjklaim@gmail.com" target=3D"_blank">mjklaim@gmail.co=
m</a>></span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margi=
n:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr">=
If my understanding is correct, this example does not work if two members h=
ave the same type.</div><div class=3D"HOEnZb"><div class=3D"h5"><div class=
=3D"gmail_extra"><br><div class=3D"gmail_quote">On Fri, Apr 24, 2015 at 6:0=
5 AM, David Krauss <span dir=3D"ltr"><<a href=3D"mailto:potswa@gmail.com=
" target=3D"_blank">potswa@gmail.com</a>></span> wrote:<br><blockquote c=
lass=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;=
padding-left:1ex"><div style=3D"word-wrap:break-word"><span><br><div><block=
quote type=3D"cite"><div>On 2015=E2=80=9304=E2=80=9324, at 11:56 AM, <a hre=
f=3D"mailto:flarn2006@gmail.com" target=3D"_blank">flarn2006@gmail.com</a> =
wrote:</div><br><div><span style=3D"font-family:Helvetica;font-size:12px;fo=
nt-style:normal;font-variant:normal;font-weight:normal;letter-spacing:norma=
l;line-height:normal;text-align:start;text-indent:0px;text-transform:none;w=
hite-space:normal;word-spacing:0px;float:none;display:inline!important">Thi=
s could basically be used for having a class with any number of members det=
ermined by template parameters, which as of now (AFAIK) is not possible. On=
e potential use this would have is making tuples look cleaner. Instead of u=
sing<span>=C2=A0</span></span><span style=3D"font-size:12px;font-style:norm=
al;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height=
:normal;text-align:start;text-indent:0px;text-transform:none;white-space:no=
rmal;word-spacing:0px;font-family:'courier new',monospace">std::get=
<2>(aTuple)</span><span style=3D"font-family:Helvetica;font-size:12px=
;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:no=
rmal;line-height:normal;text-align:start;text-indent:0px;text-transform:non=
e;white-space:normal;word-spacing:0px;float:none;display:inline!important">=
, you could use something like<span>=C2=A0</span></span><span style=3D"font=
-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-=
spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-tra=
nsform:none;white-space:normal;word-spacing:0px;font-family:'courier ne=
w',monospace">aTuple.value2</span><span style=3D"font-family:Helvetica;=
font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;let=
ter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text=
-transform:none;white-space:normal;word-spacing:0px;float:none;display:inli=
ne!important">.</span><br style=3D"font-family:Helvetica;font-size:12px;fon=
t-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal=
;line-height:normal;text-align:start;text-indent:0px;text-transform:none;wh=
ite-space:normal;word-spacing:0px"></div></blockquote></div><br></span><div=
>It=E2=80=99s already possible to have <font face=3D"Courier">aTuple.value&=
lt;2>()</font>, is the difference really worth it?</div><div><br></div><=
div><font face=3D"Courier">template< typename tuple ></font></div><di=
v><font face=3D"Courier">struct memberwise_tuple : tuple {</font></div><div=
><font face=3D"Courier">=C2=A0 =C2=A0 using tuple::tuple;</font></div><div>=
<font face=3D"Courier"><br></font></div><div><font face=3D"Courier">=C2=A0 =
=C2=A0 template< std::size_t index ></font></div><div><font face=3D"C=
ourier">=C2=A0 =C2=A0 decltype(auto) value & { return std::get< inde=
x >( static_cast< tuple & >( * this ) ); }</font></div><div><f=
ont face=3D"Courier"><br></font></div><div><font face=3D"Courier">=C2=A0 =
=C2=A0 template< std::size_t index ></font></div><div><font face=3D"C=
ourier">=C2=A0 =C2=A0 decltype(auto) value const & { return std::get<=
; index >( static_cast< tuple const & >( * this ) ); }</font><=
/div><div><font face=3D"Courier"><br></font></div><div><font face=3D"Courie=
r">=C2=A0 =C2=A0 template< std::size_t index ></font></div><div><font=
face=3D"Courier">=C2=A0 =C2=A0 decltype(auto) value && { return st=
d::get< index >( static_cast< tuple && >( * this ) ); }=
</font></div><div><font face=3D"Courier">};</font></div></div><div><div>
<p></p>
-- <br>
<br>
--- <br>
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org" 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" target=3D"_blank">std-proposals@isocpp.org</a>.<br>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" target=3D"_blank">http://groups.google.com/a/isocpp.org/gro=
up/std-proposals/</a>.<br>
</div></div></blockquote></div><br></div>
<p></p>
-- <br>
<br>
--- <br>
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org" 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" target=3D"_blank">std-proposals@isocpp.org</a>.<br>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" target=3D"_blank">http://groups.google.com/a/isocpp.org/gro=
up/std-proposals/</a>.<br>
</div></div></blockquote></div><br></div></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
--089e012299d44601e6051567adb9--
.
Author: Igor Baidiuk <target.san@gmail.com>
Date: Wed, 6 May 2015 05:06:55 -0700 (PDT)
Raw View
------=_Part_410_1134760743.1430914015629
Content-Type: multipart/alternative;
boundary="----=_Part_411_121538594.1430914015629"
------=_Part_411_121538594.1430914015629
Content-Type: text/plain; charset=UTF-8
I think your case is too narrow. I'd rather concentrate on a more generic
solution, like compile-time reflection and code generation. Otherwise we'll
have thousand additions each covering some corner case. As others noted,
similar functionality is already solved by tuple's 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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
------=_Part_411_121538594.1430914015629
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><code>I think your case is too narrow. I'd rather concentr=
ate on a more generic solution, like compile-time reflection and code gener=
ation. Otherwise we'll have thousand additions each covering some corner ca=
se. As others noted, similar functionality is already solved by tuple's get=
..</code><br></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_411_121538594.1430914015629--
------=_Part_410_1134760743.1430914015629--
.
Author: hun.nemethpeter@gmail.com
Date: Wed, 6 May 2015 05:24:30 -0700 (PDT)
Raw View
------=_Part_6515_988114511.1430915070704
Content-Type: multipart/alternative;
boundary="----=_Part_6516_749544126.1430915070704"
------=_Part_6516_749544126.1430915070704
Content-Type: text/plain; charset=UTF-8
Hi!
I made a similar proposal:
https://github.com/hun-nemethpeter/cpp-reflector-mini/blob/master/constexpr-ast/constexpr_id_proposal.md
The following example is compiling now:
#include "ast.h"
void gets(); //
http://comments.gmane.org/gmane.comp.compilers.llvm.bugs/27182
#include <iostream>
constexpr const char* getVariableName()
{ return "var_name"; }
int #<(getVariableName())> = 1; // int var_name = 1;
struct TestClass
{
int #<(getVariableName())>; // int var_name;
};
namespace NS {
int #<(typeid<TestClass>.name().data().c_str())>; // int TestClass
}
int main()
{
TestClass test;
test.var_name = 2;
NS::TestClass = 3;
std::cout << var_name << std::endl;
std::cout << test.var_name << std::endl;
std::cout << NS::TestClass << std::endl;
return 0;
}
And I want extend it with a compile time for:
#<for> (item : items())
declarations or
statements
#</for>
constexpr ast is here:
https://github.com/hun-nemethpeter/cpp-reflector-mini/tree/master/constexpr-ast
The clang repo is here:
https://github.com/hun-nemethpeter/clang/tree/typid_ast
<https://www.google.com/url?q=https%3A%2F%2Fgithub.com%2Fhun-nemethpeter%2Fclang%2Ftree%2Ftypid_ast&sa=D&sntz=1&usg=AFQjCNGOFS0QP5Ek_PotfpWAXWZkgYee8A>
Peter
On Friday, April 24, 2015 at 5:56:40 AM UTC+2, flar...@gmail.com wrote:
>
> Basically, my idea is about giving members names that depend on numeric
> template parameters. An example, using (obviously) non-standardized syntax
> (as such it won't compile) to show how it might be done:
>
> #include <iostream>
>
> template <int n>
> struct Example
> {
> int value using ("value_of_" + n);
>
> Example(int myValue)
> {
> value = myValue;
> }
> }
>
> int main(int argc, char *argv[])
> {
> Example<42> ex;
> std::cout << ex.value_of_42 << std::endl; //prints 42
> return 0;
> }
>
> First off, I know this particular example wouldn't be very useful in
> practice. But it's useful as an example. Notice the nonstandard use of the
> using keyword. This keyword works very well here, reading as "Declare int
> value, using a name determined by ("value_of_" + n)."
>
> The word value here is just the name of the variable used within the
> class, which isn't visible outside the class. This is necessary because
> within the class the value of n could be anything, meaning the external
> name could also be one of many different things.
>
> This could basically be used for having a class with any number of members
> determined by template parameters, which as of now (AFAIK) is not possible.
> One potential use this would have is making tuples look cleaner. Instead of
> using std::get<2>(aTuple), you could use something like aTuple.value2.
>
> A slightly more complex example making use of inheritance to create
> multiple members with dynamic names:
>
> #include <iostream>
>
> template <int MaxValue>
> struct ListOfValues : public ListOfValues<MaxValue - 1>
> {
> const int value using ("value_of_" + MaxValue) = MaxValue;
> }
>
> template <>
> struct ListOfValues<0>
> {
> const int value_of_0 = 0;
> }
>
> int main(int argc, char *argv[])
> {
> ListOfValues<3> list;
> std::cout << list.value_of_0 << list.value_of_1 << list.value_of_2 <<
> list.value_of_3 << std::endl; //prints 0123
> return 0;
> }
>
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
------=_Part_6516_749544126.1430915070704
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Hi!<div><br></div><div>I made a similar proposal: <a =
href=3D"https://github.com/hun-nemethpeter/cpp-reflector-mini/blob/master/c=
onstexpr-ast/constexpr_id_proposal.md">https://github.com/hun-nemethpeter/c=
pp-reflector-mini/blob/master/constexpr-ast/constexpr_id_proposal.md</a></d=
iv><div><br></div><div>The following example is compiling now:</div><div><b=
r></div><div><br></div><div><span style=3D"font-family: monospace; color: r=
gb(136, 0, 0); background-color: rgb(250, 250, 250);">#include</span><span =
style=3D"font-family: monospace; color: rgb(0, 0, 0); background-color: rgb=
(250, 250, 250);"> </span><span style=3D"font-family: monospace; color=
: rgb(0, 136, 0); background-color: rgb(250, 250, 250);">"ast.h"</span><spa=
n style=3D"font-family: monospace; color: rgb(0, 0, 0); background-color: r=
gb(250, 250, 250);"><br></span><span style=3D"font-family: monospace; color=
: rgb(0, 0, 136); background-color: rgb(250, 250, 250);">void</span><span s=
tyle=3D"font-family: monospace; color: rgb(0, 0, 0); background-color: rgb(=
250, 250, 250);"> gets</span><span style=3D"font-family: monospace; co=
lor: rgb(102, 102, 0); background-color: rgb(250, 250, 250);">();</span><sp=
an style=3D"font-family: monospace; color: rgb(0, 0, 0); background-color: =
rgb(250, 250, 250);"> </span><span style=3D"font-family: monospace; co=
lor: rgb(136, 0, 0); background-color: rgb(250, 250, 250);">// <a href=
=3D"http://comments.gmane.org/gmane.comp.compilers.llvm.bugs/27182" target=
=3D"_blank" rel=3D"nofollow" style=3D"cursor: pointer;">http://comments.gma=
ne.org/<wbr>gmane.comp.compilers.llvm.<wbr>bugs/27182</a></span><span style=
=3D"font-family: monospace; color: rgb(0, 0, 0); background-color: rgb(250,=
250, 250);"><br></span><span style=3D"font-family: monospace; color: rgb(1=
36, 0, 0); background-color: rgb(250, 250, 250);">#include</span><span styl=
e=3D"font-family: monospace; color: rgb(0, 0, 0); background-color: rgb(250=
, 250, 250);"> </span><span style=3D"font-family: monospace; color: rg=
b(0, 136, 0); background-color: rgb(250, 250, 250);"><iostream></span=
><span style=3D"font-family: monospace; color: rgb(0, 0, 0); background-col=
or: rgb(250, 250, 250);"><br><br></span><span style=3D"font-family: monospa=
ce; color: rgb(0, 0, 136); background-color: rgb(250, 250, 250);">constexpr=
</span><span style=3D"font-family: monospace; color: rgb(0, 0, 0); backgrou=
nd-color: rgb(250, 250, 250);"> </span><span style=3D"font-family: mon=
ospace; color: rgb(0, 0, 136); background-color: rgb(250, 250, 250);">const=
</span><span style=3D"font-family: monospace; color: rgb(0, 0, 0); backgrou=
nd-color: rgb(250, 250, 250);"> </span><span style=3D"font-family: mon=
ospace; color: rgb(0, 0, 136); background-color: rgb(250, 250, 250);">char<=
/span><span style=3D"font-family: monospace; color: rgb(102, 102, 0); backg=
round-color: rgb(250, 250, 250);">*</span><span style=3D"font-family: monos=
pace; color: rgb(0, 0, 0); background-color: rgb(250, 250, 250);"> get=
VariableName</span><span style=3D"font-family: monospace; color: rgb(102, 1=
02, 0); background-color: rgb(250, 250, 250);">()</span><span style=3D"font=
-family: monospace; color: rgb(0, 0, 0); background-color: rgb(250, 250, 25=
0);"><br></span><span style=3D"font-family: monospace; color: rgb(102, 102,=
0); background-color: rgb(250, 250, 250);">{</span><span style=3D"font-fam=
ily: monospace; color: rgb(0, 0, 0); background-color: rgb(250, 250, 250);"=
> </span><span style=3D"font-family: monospace; color: rgb(0, 0, 136);=
background-color: rgb(250, 250, 250);">return</span><span style=3D"font-fa=
mily: monospace; color: rgb(0, 0, 0); background-color: rgb(250, 250, 250);=
"> </span><span style=3D"font-family: monospace; color: rgb(0, 136, 0)=
; background-color: rgb(250, 250, 250);">"var_name"</span><span style=3D"fo=
nt-family: monospace; color: rgb(102, 102, 0); background-color: rgb(250, 2=
50, 250);">;</span><span style=3D"font-family: monospace; color: rgb(0, 0, =
0); background-color: rgb(250, 250, 250);"> </span><span style=3D"font=
-family: monospace; color: rgb(102, 102, 0); background-color: rgb(250, 250=
, 250);">}</span><span style=3D"font-family: monospace; color: rgb(0, 0, 0)=
; background-color: rgb(250, 250, 250);"><br><br><br></span>int <span style=
=3D"background-color: rgb(255, 153, 0);">#<(getVariableName())></span=
> =3D 1; // int var_name =3D 1;<br><br>struct TestClass<br>{<br> int =
<span style=3D"background-color: rgb(255, 153, 0);">#<(getVariableName()=
)></span>; // int var_name;<br>};<br><br>namespace NS {<br>int <span sty=
le=3D"background-color: rgb(255, 153, 0);">#<(typeid<TestClass>.na=
me().data().c_str())></span>; // int TestClass<br>}<span style=3D"font-f=
amily: monospace; color: rgb(102, 102, 0); background-color: rgb(250, 250, =
250);"><br></span><span style=3D"font-family: monospace; color: rgb(0, 0, 0=
); background-color: rgb(250, 250, 250);"><br><br></span><span style=3D"fon=
t-family: monospace; color: rgb(0, 0, 136); background-color: rgb(250, 250,=
250);">int</span><span style=3D"font-family: monospace; color: rgb(0, 0, 0=
); background-color: rgb(250, 250, 250);"> main</span><span style=3D"f=
ont-family: monospace; color: rgb(102, 102, 0); background-color: rgb(250, =
250, 250);">()</span><span style=3D"font-family: monospace; color: rgb(0, 0=
, 0); background-color: rgb(250, 250, 250);"><br></span><span style=3D"font=
-family: monospace; color: rgb(102, 102, 0); background-color: rgb(250, 250=
, 250);">{</span><span style=3D"font-family: monospace; color: rgb(0, 0, 0)=
; background-color: rgb(250, 250, 250);"><br> </span><span style=
=3D"font-family: monospace; color: rgb(102, 0, 102); background-color: rgb(=
250, 250, 250);">TestClass</span><span style=3D"font-family: monospace; col=
or: rgb(0, 0, 0); background-color: rgb(250, 250, 250);"> test</span><=
span style=3D"font-family: monospace; color: rgb(102, 102, 0); background-c=
olor: rgb(250, 250, 250);">;</span><span style=3D"font-family: monospace; c=
olor: rgb(0, 0, 0); background-color: rgb(250, 250, 250);"><br> test<=
/span><span style=3D"font-family: monospace; color: rgb(102, 102, 0); backg=
round-color: rgb(250, 250, 250);">.</span><span style=3D"font-family: monos=
pace; color: rgb(0, 0, 0); background-color: rgb(250, 250, 250);">var_name&=
nbsp;</span><span style=3D"font-family: monospace; color: rgb(102, 102, 0);=
background-color: rgb(250, 250, 250);">=3D</span><span style=3D"font-famil=
y: monospace; color: rgb(0, 0, 0); background-color: rgb(250, 250, 250);">&=
nbsp;</span><span style=3D"font-family: monospace; color: rgb(0, 102, 102);=
background-color: rgb(250, 250, 250);">2</span><span style=3D"font-family:=
monospace; color: rgb(102, 102, 0); background-color: rgb(250, 250, 250);"=
>;</span><span style=3D"font-family: monospace; color: rgb(0, 0, 0); backgr=
ound-color: rgb(250, 250, 250);"><br> NS</span><span style=3D"font-fa=
mily: monospace; color: rgb(102, 102, 0); background-color: rgb(250, 250, 2=
50);">::</span><span style=3D"font-family: monospace; color: rgb(102, 0, 10=
2); background-color: rgb(250, 250, 250);">TestClass</span><span style=3D"f=
ont-family: monospace; color: rgb(0, 0, 0); background-color: rgb(250, 250,=
250);"> </span><span style=3D"font-family: monospace; color: rgb(102,=
102, 0); background-color: rgb(250, 250, 250);">=3D</span><span style=3D"f=
ont-family: monospace; color: rgb(0, 0, 0); background-color: rgb(250, 250,=
250);"> </span><span style=3D"font-family: monospace; color: rgb(0, 1=
02, 102); background-color: rgb(250, 250, 250);">3</span><span style=3D"fon=
t-family: monospace; color: rgb(102, 102, 0); background-color: rgb(250, 25=
0, 250);">;</span><span style=3D"font-family: monospace; color: rgb(0, 0, 0=
); background-color: rgb(250, 250, 250);"><br> std</span><span style=
=3D"font-family: monospace; color: rgb(102, 102, 0); background-color: rgb(=
250, 250, 250);">::</span><span style=3D"font-family: monospace; color: rgb=
(0, 0, 0); background-color: rgb(250, 250, 250);">cout </span><span st=
yle=3D"font-family: monospace; color: rgb(102, 102, 0); background-color: r=
gb(250, 250, 250);"><<</span><span style=3D"font-family: monospace; c=
olor: rgb(0, 0, 0); background-color: rgb(250, 250, 250);"> var_name&n=
bsp;</span><span style=3D"font-family: monospace; color: rgb(102, 102, 0); =
background-color: rgb(250, 250, 250);"><<</span><span style=3D"font-f=
amily: monospace; color: rgb(0, 0, 0); background-color: rgb(250, 250, 250)=
;"> std</span><span style=3D"font-family: monospace; color: rgb(102, 1=
02, 0); background-color: rgb(250, 250, 250);">::</span><span style=3D"font=
-family: monospace; color: rgb(0, 0, 0); background-color: rgb(250, 250, 25=
0);">endl</span><span style=3D"font-family: monospace; color: rgb(102, 102,=
0); background-color: rgb(250, 250, 250);">;</span><span style=3D"font-fam=
ily: monospace; color: rgb(0, 0, 0); background-color: rgb(250, 250, 250);"=
><br> std</span><span style=3D"font-family: monospace; color: rgb(102=
, 102, 0); background-color: rgb(250, 250, 250);">::</span><span style=3D"f=
ont-family: monospace; color: rgb(0, 0, 0); background-color: rgb(250, 250,=
250);">cout </span><span style=3D"font-family: monospace; color: rgb(=
102, 102, 0); background-color: rgb(250, 250, 250);"><<</span><span s=
tyle=3D"font-family: monospace; color: rgb(0, 0, 0); background-color: rgb(=
250, 250, 250);"> test</span><span style=3D"font-family: monospace; co=
lor: rgb(102, 102, 0); background-color: rgb(250, 250, 250);">.</span><span=
style=3D"font-family: monospace; color: rgb(0, 0, 0); background-color: rg=
b(250, 250, 250);">var_name </span><span style=3D"font-family: monospa=
ce; color: rgb(102, 102, 0); background-color: rgb(250, 250, 250);"><<=
;</span><span style=3D"font-family: monospace; color: rgb(0, 0, 0); backgro=
und-color: rgb(250, 250, 250);"> std</span><span style=3D"font-family:=
monospace; color: rgb(102, 102, 0); background-color: rgb(250, 250, 250);"=
>::</span><span style=3D"font-family: monospace; color: rgb(0, 0, 0); backg=
round-color: rgb(250, 250, 250);">endl</span><span style=3D"font-family: mo=
nospace; color: rgb(102, 102, 0); background-color: rgb(250, 250, 250);">;<=
/span><span style=3D"font-family: monospace; color: rgb(0, 0, 0); backgroun=
d-color: rgb(250, 250, 250);"><br> std</span><span style=3D"font-fami=
ly: monospace; color: rgb(102, 102, 0); background-color: rgb(250, 250, 250=
);">::</span><span style=3D"font-family: monospace; color: rgb(0, 0, 0); ba=
ckground-color: rgb(250, 250, 250);">cout </span><span style=3D"font-f=
amily: monospace; color: rgb(102, 102, 0); background-color: rgb(250, 250, =
250);"><<</span><span style=3D"font-family: monospace; color: rgb(0, =
0, 0); background-color: rgb(250, 250, 250);"> NS</span><span style=3D=
"font-family: monospace; color: rgb(102, 102, 0); background-color: rgb(250=
, 250, 250);">::</span><span style=3D"font-family: monospace; color: rgb(10=
2, 0, 102); background-color: rgb(250, 250, 250);">TestClass</span><span st=
yle=3D"font-family: monospace; color: rgb(0, 0, 0); background-color: rgb(2=
50, 250, 250);"> </span><span style=3D"font-family: monospace; color: =
rgb(102, 102, 0); background-color: rgb(250, 250, 250);"><<</span><sp=
an style=3D"font-family: monospace; color: rgb(0, 0, 0); background-color: =
rgb(250, 250, 250);"> std</span><span style=3D"font-family: monospace;=
color: rgb(102, 102, 0); background-color: rgb(250, 250, 250);">::</span><=
span style=3D"font-family: monospace; color: rgb(0, 0, 0); background-color=
: rgb(250, 250, 250);">endl</span><span style=3D"font-family: monospace; co=
lor: rgb(102, 102, 0); background-color: rgb(250, 250, 250);">;</span><span=
style=3D"font-family: monospace; color: rgb(0, 0, 0); background-color: rg=
b(250, 250, 250);"><br><br> </span><span style=3D"font-family: m=
onospace; color: rgb(0, 0, 136); background-color: rgb(250, 250, 250);">ret=
urn</span><span style=3D"font-family: monospace; color: rgb(0, 0, 0); backg=
round-color: rgb(250, 250, 250);"> </span><span style=3D"font-family: =
monospace; color: rgb(0, 102, 102); background-color: rgb(250, 250, 250);">=
0</span><span style=3D"font-family: monospace; color: rgb(102, 102, 0); bac=
kground-color: rgb(250, 250, 250);">;</span><span style=3D"font-family: mon=
ospace; color: rgb(0, 0, 0); background-color: rgb(250, 250, 250);"><br></s=
pan><span style=3D"font-family: monospace; color: rgb(102, 102, 0); backgro=
und-color: rgb(250, 250, 250);">}</span><br></div><div><br></div><div>And I=
want extend it with a compile time for:</div><div><pre style=3D"box-sizing=
: border-box; overflow: auto; font-family: Consolas, 'Liberation Mono', Men=
lo, Courier, monospace; font-size: 13.6000003814697px; font-stretch: normal=
; line-height: 1.45; padding: 16px; border-radius: 3px; word-wrap: normal; =
word-break: normal; color: rgb(51, 51, 51); background-color: rgb(247, 247,=
247);"> #<<span class=3D"pl-k" style=3D"box-sizing: border-box; color:=
rgb(167, 29, 93);">for</span>> (item : items())
declarations <span class=3D"pl-k" style=3D"box-sizing: border-box; col=
or: rgb(167, 29, 93);">or</span>
statements
#</<span class=3D"pl-k" style=3D"box-sizing: border-box; color: rgb(16=
7, 29, 93);">for</span>></pre></div><div><br></div><div>constexpr ast is=
here:</div><div><a href=3D"https://github.com/hun-nemethpeter/cpp-reflecto=
r-mini/tree/master/constexpr-ast">https://github.com/hun-nemethpeter/cpp-re=
flector-mini/tree/master/constexpr-ast</a><br></div><div><br></div><div>The=
clang repo is here:<br><a href=3D"https://www.google.com/url?q=3Dhttps%3A%=
2F%2Fgithub.com%2Fhun-nemethpeter%2Fclang%2Ftree%2Ftypid_ast&sa=3DD&=
;sntz=3D1&usg=3DAFQjCNGOFS0QP5Ek_PotfpWAXWZkgYee8A" target=3D"_blank" r=
el=3D"nofollow" style=3D"cursor: pointer;">https://github.com/hun-<wbr>neme=
thpeter/clang/tree/typid_<wbr>ast</a><br></div><div><br></div><div>Peter<br=
><br>On Friday, April 24, 2015 at 5:56:40 AM UTC+2, flar...@gmail.com wrote=
:<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">Basically, m=
y idea is about giving members names that depend on numeric template parame=
ters. An example, using (obviously) non-standardized syntax (as such it won=
't compile) to show how it might be done:<br><br><div style=3D"background-c=
olor:rgb(250,250,250);border-color:rgb(187,187,187);border-style:solid;bord=
er-width:1px;word-wrap:break-word"><code><div><span style=3D"color:#800">#i=
nclude</span><span style=3D"color:#000"> </span><span style=3D"color:#080">=
<iostream></span><span style=3D"color:#000"><br><br></span><span styl=
e=3D"color:#008">template</span><span style=3D"color:#000"> </span><span st=
yle=3D"color:#660"><</span><span style=3D"color:#008">int</span><span st=
yle=3D"color:#000"> n</span><span style=3D"color:#660">></span><span sty=
le=3D"color:#000"><br></span><span style=3D"color:#008">struct</span><span =
style=3D"color:#000"> </span><span style=3D"color:#606">Example</span><span=
style=3D"color:#000"><br></span><span style=3D"color:#660">{</span><span s=
tyle=3D"color:#000"><br> </span><span style=3D"color:#008">int=
</span><span style=3D"color:#000"> value </span><span style=3D"color:#008">=
using</span><span style=3D"color:#000"> </span><span style=3D"color:#660">(=
</span><span style=3D"color:#080">"value_of_"</span><span style=3D"color:#0=
00"> </span><span style=3D"color:#660">+</span><span style=3D"color:#000"> =
n</span><span style=3D"color:#660">);</span><span style=3D"color:#000"><br>=
<br> </span><span style=3D"color:#606">Example</span><span sty=
le=3D"color:#660">(</span><span style=3D"color:#008">int</span><span style=
=3D"color:#000"> myValue</span><span style=3D"color:#660">)</span><span sty=
le=3D"color:#000"><br> </span><span style=3D"color:#660">{</sp=
an><span style=3D"color:#000"><br> value </span>=
<span style=3D"color:#660">=3D</span><span style=3D"color:#000"> myValue</s=
pan><span style=3D"color:#660">;</span><span style=3D"color:#000"><br> =
; </span><span style=3D"color:#660">}</span><span style=3D"color:#00=
0"><br></span><span style=3D"color:#660">}</span><span style=3D"color:#000"=
><br><br></span><span style=3D"color:#008">int</span><span style=3D"color:#=
000"> main</span><span style=3D"color:#660">(</span><span style=3D"color:#0=
08">int</span><span style=3D"color:#000"> argc</span><span style=3D"color:#=
660">,</span><span style=3D"color:#000"> </span><span style=3D"color:#008">=
char</span><span style=3D"color:#000"> </span><span style=3D"color:#660">*<=
/span><span style=3D"color:#000">argv</span><span style=3D"color:#660">[])<=
/span><span style=3D"color:#000"><br></span><span style=3D"color:#660">{</s=
pan><span style=3D"color:#000"><br> </span><span style=3D"colo=
r:#606">Example</span><span style=3D"color:#660"><</span><span style=3D"=
color:#066">42</span><span style=3D"color:#660">></span><span style=3D"c=
olor:#000"> ex</span><span style=3D"color:#660">;</span><span style=3D"colo=
r:#000"><br> std</span><span style=3D"color:#660">::</span><sp=
an style=3D"color:#000">cout </span><span style=3D"color:#660"><<</sp=
an><span style=3D"color:#000"> ex</span><span style=3D"color:#660">.</span>=
<span style=3D"color:#000">value_of_42 </span><span style=3D"color:#660">&l=
t;<</span><span style=3D"color:#000"> std</span><span style=3D"color:#66=
0">::</span><span style=3D"color:#000">endl</span><span style=3D"color:#660=
">;</span><span style=3D"color:#000"> </span><span style=3D"color:#800">//p=
rints 42</span><span style=3D"color:#000"><br> </span><span st=
yle=3D"color:#008">return</span><span style=3D"color:#000"> </span><span st=
yle=3D"color:#066">0</span><span style=3D"color:#660">;</span><span style=
=3D"color:#000"><br></span><span style=3D"color:#660">}</span><span style=
=3D"color:#000"><br></span></div></code></div><br>First off, I know this pa=
rticular example wouldn't be very useful in practice. But it's useful as an=
example. Notice the nonstandard use of the <span style=3D"font-family:cour=
ier new,monospace">using</span> keyword. This keyword works very well here,=
reading as "Declare <span style=3D"font-family:courier new,monospace">int =
value</span>, <span style=3D"font-family:courier new,monospace">using</span=
> a name determined by <span style=3D"font-family:courier new,monospace">("=
value_of_" + n)</span>."<br><br>The word <span style=3D"font-family:courier=
new,monospace">value</span> here is just the name of the variable used wit=
hin the class, which isn't visible outside the class. This is necessary bec=
ause within the class the value of <span style=3D"font-family:courier new,m=
onospace">n</span> could be anything, meaning the external name could also =
be one of many different things.<br><br>This could basically be used for ha=
ving a class with any number of members determined by template parameters, =
which as of now (AFAIK) is not possible. One potential use this would have =
is making tuples look cleaner. Instead of using <span style=3D"font-family:=
courier new,monospace">std::get<2>(aTuple)</span>, you could use some=
thing like <span style=3D"font-family:courier new,monospace">aTuple.value2<=
/span>.<br><br>A slightly more complex example making use of inheritance to=
create multiple members with dynamic names:<br><br><div style=3D"backgroun=
d-color:rgb(250,250,250);border-color:rgb(187,187,187);border-style:solid;b=
order-width:1px;word-wrap:break-word"><code><div><span style=3D"color:#800"=
>#include</span><span style=3D"color:#000"> </span><span style=3D"color:#08=
0"><iostream></span><span style=3D"color:#000"><br> <br></span><=
span style=3D"color:#008">template</span><span style=3D"color:#000"> </span=
><span style=3D"color:#660"><</span><span style=3D"color:#008">int</span=
><span style=3D"color:#000"> </span><span style=3D"color:#606">MaxValue</sp=
an><span style=3D"color:#660">></span><span style=3D"color:#000"><br></s=
pan><span style=3D"color:#008">struct</span><span style=3D"color:#000"> </s=
pan><span style=3D"color:#606">ListOfValues</span><span style=3D"color:#000=
"> </span><span style=3D"color:#660">:</span><span style=3D"color:#000"> </=
span><span style=3D"color:#008">public</span><span style=3D"color:#000"> </=
span><span style=3D"color:#606">ListOfValues</span><span style=3D"color:#66=
0"><</span><span style=3D"color:#606">MaxValue</span><span style=3D"colo=
r:#000"> </span><span style=3D"color:#660">-</span><span style=3D"color:#00=
0"> </span><span style=3D"color:#066">1</span><span style=3D"color:#660">&g=
t;</span><span style=3D"color:#000"><br></span><span style=3D"color:#660">{=
</span><span style=3D"color:#000"><br> </span><span style=3D"c=
olor:#008">const</span><span style=3D"color:#000"> </span><span style=3D"co=
lor:#008">int</span><span style=3D"color:#000"> value </span><span style=3D=
"color:#008">using</span><span style=3D"color:#000"> </span><span style=3D"=
color:#660">(</span><span style=3D"color:#080">"value_of_"</span><span styl=
e=3D"color:#000"> </span><span style=3D"color:#660">+</span><span style=3D"=
color:#000"> </span><span style=3D"color:#606">MaxValue</span><span style=
=3D"color:#660">)</span><span style=3D"color:#000"> </span><span style=3D"c=
olor:#660">=3D</span><span style=3D"color:#000"> </span><span style=3D"colo=
r:#606">MaxValue</span><span style=3D"color:#660">;</span><span style=3D"co=
lor:#000"><br></span><span style=3D"color:#660">}</span><span style=3D"colo=
r:#000"><br> <br></span><span style=3D"color:#008">template</span><spa=
n style=3D"color:#000"> </span><span style=3D"color:#660"><></span><s=
pan style=3D"color:#000"><br></span><span style=3D"color:#008">struct</span=
><span style=3D"color:#000"> </span><span style=3D"color:#606">ListOfValues=
</span><span style=3D"color:#660"><</span><span style=3D"color:#066">0</=
span><span style=3D"color:#660">></span><span style=3D"color:#000"><br><=
/span><span style=3D"color:#660">{</span><span style=3D"color:#000"><br>&nb=
sp; </span><span style=3D"color:#008">const</span><span style=3D"col=
or:#000"> </span><span style=3D"color:#008">int</span><span style=3D"color:=
#000"> value_of_0 </span><span style=3D"color:#660">=3D</span><span style=
=3D"color:#000"> </span><span style=3D"color:#066">0</span><span style=3D"c=
olor:#660">;</span><span style=3D"color:#000"><br></span><span style=3D"col=
or:#660">}</span><span style=3D"color:#000"><br> <br></span><span styl=
e=3D"color:#008">int</span><span style=3D"color:#000"> main</span><span sty=
le=3D"color:#660">(</span><span style=3D"color:#008">int</span><span style=
=3D"color:#000"> argc</span><span style=3D"color:#660">,</span><span style=
=3D"color:#000"> </span><span style=3D"color:#008">char</span><span style=
=3D"color:#000"> </span><span style=3D"color:#660">*</span><span style=3D"c=
olor:#000">argv</span><span style=3D"color:#660">[])</span><span style=3D"c=
olor:#000"><br></span><span style=3D"color:#660">{</span><span style=3D"col=
or:#000"><br> </span><span style=3D"color:#606">ListOfValues</=
span><span style=3D"color:#660"><</span><span style=3D"color:#066">3</sp=
an><span style=3D"color:#660">></span><span style=3D"color:#000"> list</=
span><span style=3D"color:#660">;</span><span style=3D"color:#000"><br>&nbs=
p; std</span><span style=3D"color:#660">::</span><span style=3D"colo=
r:#000">cout </span><span style=3D"color:#660"><<</span><span style=
=3D"color:#000"> list</span><span style=3D"color:#660">.</span><span style=
=3D"color:#000">value_of_0 </span><span style=3D"color:#660"><<</span=
><span style=3D"color:#000"> list</span><span style=3D"color:#660">.</span>=
<span style=3D"color:#000">value_of_1 </span><span style=3D"color:#660"><=
;<</span><span style=3D"color:#000"> list</span><span style=3D"color:#66=
0">.</span><span style=3D"color:#000">value_of_2 </span><span style=3D"colo=
r:#660"><<</span><span style=3D"color:#000"> list</span><span style=
=3D"color:#660">.</span><span style=3D"color:#000">value_of_3 </span><span =
style=3D"color:#660"><<</span><span style=3D"color:#000"> std</span><=
span style=3D"color:#660">::</span><span style=3D"color:#000">endl</span><s=
pan style=3D"color:#660">;</span><span style=3D"color:#000"> </span><span s=
tyle=3D"color:#800">//prints 0123</span><span style=3D"color:#000"><br>&nbs=
p; </span><span style=3D"color:#008">return</span><span style=3D"col=
or:#000"> </span><span style=3D"color:#066">0</span><span style=3D"color:#6=
60">;</span><span style=3D"color:#000"><br></span><span style=3D"color:#660=
">}</span><span style=3D"color:#000"><br></span></div></code></div></div></=
blockquote></div></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_6516_749544126.1430915070704--
------=_Part_6515_988114511.1430915070704--
.
Author: Igor Baidiuk <target.san@gmail.com>
Date: Wed, 6 May 2015 05:38:04 -0700 (PDT)
Raw View
------=_Part_60_436741311.1430915884019
Content-Type: multipart/alternative;
boundary="----=_Part_61_30142530.1430915884023"
------=_Part_61_30142530.1430915884023
Content-Type: text/plain; charset=UTF-8
Just curious. Is it possible for CLang to have different semantics on some
block?
Like, [[macro]] { ... different semantics go here ... };
This would allow to use more convenient syntax, without those strange #<for>
Or, maybe, have #<( compile-time manipulation goes here )>
I thought about CT reflection in C++ similar to one in Nemerle, where
compile-time macros were special kind of functions which produced AST nodes
instead of ordinary values, and some kind of quasi-quotation syntax inside
macro blocks to easily specify pieces of code.
On Wednesday, May 6, 2015 at 3:24:30 PM UTC+3, hun.nem...@gmail.com wrote:
>
> Hi!
>
> I made a similar proposal:
> https://github.com/hun-nemethpeter/cpp-reflector-mini/blob/master/constexpr-ast/constexpr_id_proposal.md
>
> The following example is compiling now:
>
>
> #include "ast.h"
> void gets(); //
> http://comments.gmane.org/gmane.comp.compilers.llvm.bugs/27182
> #include <iostream>
>
> constexpr const char* getVariableName()
> { return "var_name"; }
>
>
> int #<(getVariableName())> = 1; // int var_name = 1;
>
> struct TestClass
> {
> int #<(getVariableName())>; // int var_name;
> };
>
> namespace NS {
> int #<(typeid<TestClass>.name().data().c_str())>; // int TestClass
> }
>
>
> int main()
> {
> TestClass test;
> test.var_name = 2;
> NS::TestClass = 3;
> std::cout << var_name << std::endl;
> std::cout << test.var_name << std::endl;
> std::cout << NS::TestClass << std::endl;
>
> return 0;
> }
>
> And I want extend it with a compile time for:
>
> #<for> (item : items())
> declarations or
> statements
> #</for>
>
>
> constexpr ast is here:
>
> https://github.com/hun-nemethpeter/cpp-reflector-mini/tree/master/constexpr-ast
>
> The clang repo is here:
> https://github.com/hun-nemethpeter/clang/tree/typid_ast
> <https://www.google.com/url?q=https%3A%2F%2Fgithub.com%2Fhun-nemethpeter%2Fclang%2Ftree%2Ftypid_ast&sa=D&sntz=1&usg=AFQjCNGOFS0QP5Ek_PotfpWAXWZkgYee8A>
>
> Peter
>
> On Friday, April 24, 2015 at 5:56:40 AM UTC+2, flar...@gmail.com wrote:
>>
>> Basically, my idea is about giving members names that depend on numeric
>> template parameters. An example, using (obviously) non-standardized syntax
>> (as such it won't compile) to show how it might be done:
>>
>> #include <iostream>
>>
>> template <int n>
>> struct Example
>> {
>> int value using ("value_of_" + n);
>>
>> Example(int myValue)
>> {
>> value = myValue;
>> }
>> }
>>
>> int main(int argc, char *argv[])
>> {
>> Example<42> ex;
>> std::cout << ex.value_of_42 << std::endl; //prints 42
>> return 0;
>> }
>>
>> First off, I know this particular example wouldn't be very useful in
>> practice. But it's useful as an example. Notice the nonstandard use of the
>> using keyword. This keyword works very well here, reading as "Declare int
>> value, using a name determined by ("value_of_" + n)."
>>
>> The word value here is just the name of the variable used within the
>> class, which isn't visible outside the class. This is necessary because
>> within the class the value of n could be anything, meaning the external
>> name could also be one of many different things.
>>
>> This could basically be used for having a class with any number of
>> members determined by template parameters, which as of now (AFAIK) is not
>> possible. One potential use this would have is making tuples look cleaner.
>> Instead of using std::get<2>(aTuple), you could use something like
>> aTuple.value2.
>>
>> A slightly more complex example making use of inheritance to create
>> multiple members with dynamic names:
>>
>> #include <iostream>
>>
>> template <int MaxValue>
>> struct ListOfValues : public ListOfValues<MaxValue - 1>
>> {
>> const int value using ("value_of_" + MaxValue) = MaxValue;
>> }
>>
>> template <>
>> struct ListOfValues<0>
>> {
>> const int value_of_0 = 0;
>> }
>>
>> int main(int argc, char *argv[])
>> {
>> ListOfValues<3> list;
>> std::cout << list.value_of_0 << list.value_of_1 << list.value_of_2 <<
>> list.value_of_3 << std::endl; //prints 0123
>> return 0;
>> }
>>
>
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
------=_Part_61_30142530.1430915884023
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Just curious. Is it possible for CLang to have different s=
emantics on some block?<br>Like, [[macro]] { ... different semantics go her=
e ... };<br>This would allow to use more convenient syntax, without those s=
trange #<for><br>Or, maybe, have #<( compile-time manipulation goe=
s here )><br><br>I thought about CT reflection in C++ similar to one in =
Nemerle, where compile-time macros were special kind of functions which pro=
duced AST nodes instead of ordinary values, and some kind of quasi-quotatio=
n syntax inside macro blocks to easily specify pieces of code.<br><br>On We=
dnesday, May 6, 2015 at 3:24:30 PM UTC+3, hun.nem...@gmail.com wrote:<block=
quote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-le=
ft: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr">Hi!<div><br></div><=
div>I made a similar proposal: <a href=3D"https://github.com/hun-nemet=
hpeter/cpp-reflector-mini/blob/master/constexpr-ast/constexpr_id_proposal.m=
d" target=3D"_blank" rel=3D"nofollow" onmousedown=3D"this.href=3D'https://w=
ww.google.com/url?q\75https%3A%2F%2Fgithub.com%2Fhun-nemethpeter%2Fcpp-refl=
ector-mini%2Fblob%2Fmaster%2Fconstexpr-ast%2Fconstexpr_id_proposal.md\46sa\=
75D\46sntz\0751\46usg\75AFQjCNGk8qzLjVMcKU_Mm2AN3kzmdxA3cA';return true;" o=
nclick=3D"this.href=3D'https://www.google.com/url?q\75https%3A%2F%2Fgithub.=
com%2Fhun-nemethpeter%2Fcpp-reflector-mini%2Fblob%2Fmaster%2Fconstexpr-ast%=
2Fconstexpr_id_proposal.md\46sa\75D\46sntz\0751\46usg\75AFQjCNGk8qzLjVMcKU_=
Mm2AN3kzmdxA3cA';return true;">https://github.com/<wbr>hun-nemethpeter/cpp-=
reflector-<wbr>mini/blob/master/constexpr-<wbr>ast/constexpr_id_proposal.md=
</a></div><div><br></div><div>The following example is compiling now:</div>=
<div><br></div><div><br></div><div><span style=3D"font-family:monospace;col=
or:rgb(136,0,0);background-color:rgb(250,250,250)">#include</span><span sty=
le=3D"font-family:monospace;color:rgb(0,0,0);background-color:rgb(250,250,2=
50)"> </span><span style=3D"font-family:monospace;color:rgb(0,136,0);b=
ackground-color:rgb(250,250,250)">"ast.h"</span><span style=3D"font-family:=
monospace;color:rgb(0,0,0);background-color:rgb(250,250,250)"><br></span><s=
pan style=3D"font-family:monospace;color:rgb(0,0,136);background-color:rgb(=
250,250,250)">void</span><span style=3D"font-family:monospace;color:rgb(0,0=
,0);background-color:rgb(250,250,250)"> gets</span><span style=3D"font=
-family:monospace;color:rgb(102,102,0);background-color:rgb(250,250,250)">(=
);</span><span style=3D"font-family:monospace;color:rgb(0,0,0);background-c=
olor:rgb(250,250,250)"> </span><span style=3D"font-family:monospace;co=
lor:rgb(136,0,0);background-color:rgb(250,250,250)">// <a href=3D"http=
://comments.gmane.org/gmane.comp.compilers.llvm.bugs/27182" rel=3D"nofollow=
" target=3D"_blank" onmousedown=3D"this.href=3D'http://www.google.com/url?q=
\75http%3A%2F%2Fcomments.gmane.org%2Fgmane.comp.compilers.llvm.bugs%2F27182=
\46sa\75D\46sntz\0751\46usg\75AFQjCNHyzGdabUnWjq1CGxjPfTIR7HO6uA';return tr=
ue;" onclick=3D"this.href=3D'http://www.google.com/url?q\75http%3A%2F%2Fcom=
ments.gmane.org%2Fgmane.comp.compilers.llvm.bugs%2F27182\46sa\75D\46sntz\07=
51\46usg\75AFQjCNHyzGdabUnWjq1CGxjPfTIR7HO6uA';return true;">http://<wbr>co=
mments.gmane.org/gmane.comp.<wbr>compilers.llvm.bugs/27182</a></span><span =
style=3D"font-family:monospace;color:rgb(0,0,0);background-color:rgb(250,25=
0,250)"><br></span><span style=3D"font-family:monospace;color:rgb(136,0,0);=
background-color:rgb(250,250,250)">#include</span><span style=3D"font-famil=
y:monospace;color:rgb(0,0,0);background-color:rgb(250,250,250)"> </spa=
n><span style=3D"font-family:monospace;color:rgb(0,136,0);background-color:=
rgb(250,250,250)"><iostream></span><span style=3D"font-family:monospa=
ce;color:rgb(0,0,0);background-color:rgb(250,250,250)"><br><br></span><span=
style=3D"font-family:monospace;color:rgb(0,0,136);background-color:rgb(250=
,250,250)">constexpr</span><span style=3D"font-family:monospace;color:rgb(0=
,0,0);background-color:rgb(250,250,250)"> </span><span style=3D"font-f=
amily:monospace;color:rgb(0,0,136);background-color:rgb(250,250,250)">const=
</span><span style=3D"font-family:monospace;color:rgb(0,0,0);background-col=
or:rgb(250,250,250)"> </span><span style=3D"font-family:monospace;colo=
r:rgb(0,0,136);background-color:rgb(250,250,250)">char</span><span style=3D=
"font-family:monospace;color:rgb(102,102,0);background-color:rgb(250,250,25=
0)">*</span><span style=3D"font-family:monospace;color:rgb(0,0,0);backgroun=
d-color:rgb(250,250,250)"> <wbr>getVariableName</span><span style=3D"f=
ont-family:monospace;color:rgb(102,102,0);background-color:rgb(250,250,250)=
">()</span><span style=3D"font-family:monospace;color:rgb(0,0,0);background=
-color:rgb(250,250,250)"><br></span><span style=3D"font-family:monospace;co=
lor:rgb(102,102,0);background-color:rgb(250,250,250)">{</span><span style=
=3D"font-family:monospace;color:rgb(0,0,0);background-color:rgb(250,250,250=
)"> </span><span style=3D"font-family:monospace;color:rgb(0,0,136);bac=
kground-color:rgb(250,250,250)">return</span><span style=3D"font-family:mon=
ospace;color:rgb(0,0,0);background-color:rgb(250,250,250)"> </span><sp=
an style=3D"font-family:monospace;color:rgb(0,136,0);background-color:rgb(2=
50,250,250)">"var_name"</span><span style=3D"font-family:monospace;color:rg=
b(102,102,0);background-color:rgb(250,250,250)">;</span><span style=3D"font=
-family:monospace;color:rgb(0,0,0);background-color:rgb(250,250,250)"> =
;</span><span style=3D"font-family:monospace;color:rgb(102,102,0);backgroun=
d-color:rgb(250,250,250)">}</span><span style=3D"font-family:monospace;colo=
r:rgb(0,0,0);background-color:rgb(250,250,250)"><br><br><br></span>int <spa=
n style=3D"background-color:rgb(255,153,0)">#<(getVariableName())></s=
pan> =3D 1; // int var_name =3D 1;<br><br>struct TestClass<br>{<br> i=
nt <span style=3D"background-color:rgb(255,153,0)">#<(getVariableName())=
></span>; // int var_name;<br>};<br><br>namespace NS {<br>int <span styl=
e=3D"background-color:rgb(255,153,0)">#<(typeid<TestClass>.name().=
<wbr>data().c_str())></span>; // int TestClass<br>}<span style=3D"font-f=
amily:monospace;color:rgb(102,102,0);background-color:rgb(250,250,250)"><br=
></span><span style=3D"font-family:monospace;color:rgb(0,0,0);background-co=
lor:rgb(250,250,250)"><br><br></span><span style=3D"font-family:monospace;c=
olor:rgb(0,0,136);background-color:rgb(250,250,250)">int</span><span style=
=3D"font-family:monospace;color:rgb(0,0,0);background-color:rgb(250,250,250=
)"> main</span><span style=3D"font-family:monospace;color:rgb(102,102,=
0);background-color:rgb(250,250,250)">()</span><span style=3D"font-family:m=
onospace;color:rgb(0,0,0);background-color:rgb(250,250,250)"><br></span><sp=
an style=3D"font-family:monospace;color:rgb(102,102,0);background-color:rgb=
(250,250,250)">{</span><span style=3D"font-family:monospace;color:rgb(0,0,0=
);background-color:rgb(250,250,250)"><br> </span><span style=3D"=
font-family:monospace;color:rgb(102,0,102);background-color:rgb(250,250,250=
)">TestClass</span><span style=3D"font-family:monospace;color:rgb(0,0,0);ba=
ckground-color:rgb(250,250,250)"> test</span><span style=3D"font-famil=
y:monospace;color:rgb(102,102,0);background-color:rgb(250,250,250)">;</span=
><span style=3D"font-family:monospace;color:rgb(0,0,0);background-color:rgb=
(250,250,250)"><br> test</span><span style=3D"font-family:monospace;c=
olor:rgb(102,102,0);background-color:rgb(250,250,250)">.</span><span style=
=3D"font-family:monospace;color:rgb(0,0,0);background-color:rgb(250,250,250=
)">var_name </span><span style=3D"font-family:monospace;color:rgb(102,=
102,0);background-color:rgb(250,250,250)">=3D</span><span style=3D"font-fam=
ily:monospace;color:rgb(0,0,0);background-color:rgb(250,250,250)"> </s=
pan><span style=3D"font-family:monospace;color:rgb(0,102,102);background-co=
lor:rgb(250,250,250)">2</span><span style=3D"font-family:monospace;color:rg=
b(102,102,0);background-color:rgb(250,250,250)">;</span><span style=3D"font=
-family:monospace;color:rgb(0,0,0);background-color:rgb(250,250,250)"><br>&=
nbsp; NS</span><span style=3D"font-family:monospace;color:rgb(102,102,0);ba=
ckground-color:rgb(250,250,250)">::</span><span style=3D"font-family:monosp=
ace;color:rgb(102,0,102);background-color:rgb(250,250,250)">TestClass</span=
><span style=3D"font-family:monospace;color:rgb(0,0,0);background-color:rgb=
(250,250,250)"> </span><span style=3D"font-family:monospace;color:rgb(=
102,102,0);background-color:rgb(250,250,250)">=3D</span><span style=3D"font=
-family:monospace;color:rgb(0,0,0);background-color:rgb(250,250,250)"> =
;</span><span style=3D"font-family:monospace;color:rgb(0,102,102);backgroun=
d-color:rgb(250,250,250)">3</span><span style=3D"font-family:monospace;colo=
r:rgb(102,102,0);background-color:rgb(250,250,250)">;</span><span style=3D"=
font-family:monospace;color:rgb(0,0,0);background-color:rgb(250,250,250)"><=
br> std</span><span style=3D"font-family:monospace;color:rgb(102,102,=
0);background-color:rgb(250,250,250)">::</span><span style=3D"font-family:m=
onospace;color:rgb(0,0,0);background-color:rgb(250,250,250)">cout </sp=
an><span style=3D"font-family:monospace;color:rgb(102,102,0);background-col=
or:rgb(250,250,250)"><<</span><span style=3D"font-family:monospace;co=
lor:rgb(0,0,0);background-color:rgb(250,250,250)"> var_name </spa=
n><span style=3D"font-family:monospace;color:rgb(102,102,0);background-colo=
r:rgb(250,250,250)"><<</span><span style=3D"font-family:monospace;col=
or:rgb(0,0,0);background-color:rgb(250,250,250)"> std</span><span styl=
e=3D"font-family:monospace;color:rgb(102,102,0);background-color:rgb(250,25=
0,250)">::</span><span style=3D"font-family:monospace;color:rgb(0,0,0);back=
ground-color:rgb(250,250,250)"><wbr>endl</span><span style=3D"font-family:m=
onospace;color:rgb(102,102,0);background-color:rgb(250,250,250)">;</span><s=
pan style=3D"font-family:monospace;color:rgb(0,0,0);background-color:rgb(25=
0,250,250)"><br> std</span><span style=3D"font-family:monospace;color=
:rgb(102,102,0);background-color:rgb(250,250,250)">::</span><span style=3D"=
font-family:monospace;color:rgb(0,0,0);background-color:rgb(250,250,250)">c=
out </span><span style=3D"font-family:monospace;color:rgb(102,102,0);b=
ackground-color:rgb(250,250,250)"><<</span><span style=3D"font-family=
:monospace;color:rgb(0,0,0);background-color:rgb(250,250,250)"> test</=
span><span style=3D"font-family:monospace;color:rgb(102,102,0);background-c=
olor:rgb(250,250,250)">.</span><span style=3D"font-family:monospace;color:r=
gb(0,0,0);background-color:rgb(250,250,250)">var_name </span><span sty=
le=3D"font-family:monospace;color:rgb(102,102,0);background-color:rgb(250,2=
50,250)"><<</span><span style=3D"font-family:monospace;color:rgb(0,0,=
0);background-color:rgb(250,250,250)"> <wbr>std</span><span style=3D"f=
ont-family:monospace;color:rgb(102,102,0);background-color:rgb(250,250,250)=
">::</span><span style=3D"font-family:monospace;color:rgb(0,0,0);background=
-color:rgb(250,250,250)">endl</span><span style=3D"font-family:monospace;co=
lor:rgb(102,102,0);background-color:rgb(250,250,250)">;</span><span style=
=3D"font-family:monospace;color:rgb(0,0,0);background-color:rgb(250,250,250=
)"><br> std</span><span style=3D"font-family:monospace;color:rgb(102,=
102,0);background-color:rgb(250,250,250)">::</span><span style=3D"font-fami=
ly:monospace;color:rgb(0,0,0);background-color:rgb(250,250,250)">cout =
</span><span style=3D"font-family:monospace;color:rgb(102,102,0);background=
-color:rgb(250,250,250)"><<</span><span style=3D"font-family:monospac=
e;color:rgb(0,0,0);background-color:rgb(250,250,250)"> NS</span><span =
style=3D"font-family:monospace;color:rgb(102,102,0);background-color:rgb(25=
0,250,250)">::</span><span style=3D"font-family:monospace;color:rgb(102,0,1=
02);background-color:rgb(250,250,250)">TestClass</span><span style=3D"font-=
family:monospace;color:rgb(0,0,0);background-color:rgb(250,250,250)"> =
</span><span style=3D"font-family:monospace;color:rgb(102,102,0);background=
-color:rgb(250,250,250)"><<</span><span style=3D"font-family:monospac=
e;color:rgb(0,0,0);background-color:rgb(250,250,250)"> <wbr>std</span>=
<span style=3D"font-family:monospace;color:rgb(102,102,0);background-color:=
rgb(250,250,250)">::</span><span style=3D"font-family:monospace;color:rgb(0=
,0,0);background-color:rgb(250,250,250)">endl</span><span style=3D"font-fam=
ily:monospace;color:rgb(102,102,0);background-color:rgb(250,250,250)">;</sp=
an><span style=3D"font-family:monospace;color:rgb(0,0,0);background-color:r=
gb(250,250,250)"><br><br> </span><span style=3D"font-family:mono=
space;color:rgb(0,0,136);background-color:rgb(250,250,250)">return</span><s=
pan style=3D"font-family:monospace;color:rgb(0,0,0);background-color:rgb(25=
0,250,250)"> </span><span style=3D"font-family:monospace;color:rgb(0,1=
02,102);background-color:rgb(250,250,250)">0</span><span style=3D"font-fami=
ly:monospace;color:rgb(102,102,0);background-color:rgb(250,250,250)">;</spa=
n><span style=3D"font-family:monospace;color:rgb(0,0,0);background-color:rg=
b(250,250,250)"><br></span><span style=3D"font-family:monospace;color:rgb(1=
02,102,0);background-color:rgb(250,250,250)">}</span><br></div><div><br></d=
iv><div>And I want extend it with a compile time for:</div><div><pre style=
=3D"overflow:auto;font-family:Consolas,'Liberation Mono',Menlo,Courier,mono=
space;font-size:13.6000003814697px;font-stretch:normal;line-height:1.45;pad=
ding:16px;border-radius:3px;word-wrap:normal;word-break:normal;color:rgb(51=
,51,51);background-color:rgb(247,247,247)"> #<<span style=3D"color:rgb(=
167,29,93)">for</span>> (item : items())
declarations <span style=3D"color:rgb(167,29,93)">or</span>
statements
#</<span style=3D"color:rgb(167,29,93)">for</span>></pre></div><div=
><br></div><div>constexpr ast is here:</div><div><a href=3D"https://github.=
com/hun-nemethpeter/cpp-reflector-mini/tree/master/constexpr-ast" target=3D=
"_blank" rel=3D"nofollow" onmousedown=3D"this.href=3D'https://www.google.co=
m/url?q\75https%3A%2F%2Fgithub.com%2Fhun-nemethpeter%2Fcpp-reflector-mini%2=
Ftree%2Fmaster%2Fconstexpr-ast\46sa\75D\46sntz\0751\46usg\75AFQjCNELk4euKMz=
u6stx4_2IehRCrNOaDQ';return true;" onclick=3D"this.href=3D'https://www.goog=
le.com/url?q\75https%3A%2F%2Fgithub.com%2Fhun-nemethpeter%2Fcpp-reflector-m=
ini%2Ftree%2Fmaster%2Fconstexpr-ast\46sa\75D\46sntz\0751\46usg\75AFQjCNELk4=
euKMzu6stx4_2IehRCrNOaDQ';return true;">https://github.com/hun-<wbr>nemethp=
eter/cpp-reflector-<wbr>mini/tree/master/constexpr-ast</a><br></div><div><b=
r></div><div>The clang repo is here:<br><a href=3D"https://www.google.com/u=
rl?q=3Dhttps%3A%2F%2Fgithub.com%2Fhun-nemethpeter%2Fclang%2Ftree%2Ftypid_as=
t&sa=3DD&sntz=3D1&usg=3DAFQjCNGOFS0QP5Ek_PotfpWAXWZkgYee8A" rel=
=3D"nofollow" target=3D"_blank" onmousedown=3D"this.href=3D'https://www.goo=
gle.com/url?q\75https%3A%2F%2Fgithub.com%2Fhun-nemethpeter%2Fclang%2Ftree%2=
Ftypid_ast\46sa\75D\46sntz\0751\46usg\75AFQjCNGOFS0QP5Ek_PotfpWAXWZkgYee8A'=
;return true;" onclick=3D"this.href=3D'https://www.google.com/url?q\75https=
%3A%2F%2Fgithub.com%2Fhun-nemethpeter%2Fclang%2Ftree%2Ftypid_ast\46sa\75D\4=
6sntz\0751\46usg\75AFQjCNGOFS0QP5Ek_PotfpWAXWZkgYee8A';return true;">https:=
//github.com/hun-<wbr>nemethpeter/clang/tree/typid_<wbr>ast</a><br></div><d=
iv><br></div><div>Peter<br><br>On Friday, April 24, 2015 at 5:56:40 AM UTC+=
2, <a>flar...@gmail.com</a> 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">Basically, my idea is about giving members names that dep=
end on numeric template parameters. An example, using (obviously) non-stand=
ardized syntax (as such it won't compile) to show how it might be done:<br>=
<br><div style=3D"background-color:rgb(250,250,250);border-color:rgb(187,18=
7,187);border-style:solid;border-width:1px;word-wrap:break-word"><code><div=
><span style=3D"color:#800">#include</span><span style=3D"color:#000"> </sp=
an><span style=3D"color:#080"><iostream></span><span style=3D"color:#=
000"><br><br></span><span style=3D"color:#008">template</span><span style=
=3D"color:#000"> </span><span style=3D"color:#660"><</span><span style=
=3D"color:#008">int</span><span style=3D"color:#000"> n</span><span style=
=3D"color:#660">></span><span style=3D"color:#000"><br></span><span styl=
e=3D"color:#008">struct</span><span style=3D"color:#000"> </span><span styl=
e=3D"color:#606">Example</span><span style=3D"color:#000"><br></span><span =
style=3D"color:#660">{</span><span style=3D"color:#000"><br> <=
/span><span style=3D"color:#008">int</span><span style=3D"color:#000"> valu=
e </span><span style=3D"color:#008">using</span><span style=3D"color:#000">=
</span><span style=3D"color:#660">(</span><span style=3D"color:#080">"valu=
e_of_"</span><span style=3D"color:#000"> </span><span style=3D"color:#660">=
+</span><span style=3D"color:#000"> n</span><span style=3D"color:#660">);</=
span><span style=3D"color:#000"><br><br> </span><span style=3D=
"color:#606">Example</span><span style=3D"color:#660">(</span><span style=
=3D"color:#008">int</span><span style=3D"color:#000"> myValue</span><span s=
tyle=3D"color:#660">)</span><span style=3D"color:#000"><br> </=
span><span style=3D"color:#660">{</span><span style=3D"color:#000"><br>&nbs=
p; value </span><span style=3D"color:#660">=3D</span><=
span style=3D"color:#000"> myValue</span><span style=3D"color:#660">;</span=
><span style=3D"color:#000"><br> </span><span style=3D"color:#=
660">}</span><span style=3D"color:#000"><br></span><span style=3D"color:#66=
0">}</span><span style=3D"color:#000"><br><br></span><span style=3D"color:#=
008">int</span><span style=3D"color:#000"> main</span><span style=3D"color:=
#660">(</span><span style=3D"color:#008">int</span><span style=3D"color:#00=
0"> argc</span><span style=3D"color:#660">,</span><span style=3D"color:#000=
"> </span><span style=3D"color:#008">char</span><span style=3D"color:#000">=
</span><span style=3D"color:#660">*</span><span style=3D"color:#000">argv<=
/span><span style=3D"color:#660">[])</span><span style=3D"color:#000"><br><=
/span><span style=3D"color:#660">{</span><span style=3D"color:#000"><br>&nb=
sp; </span><span style=3D"color:#606">Example</span><span style=3D"c=
olor:#660"><</span><span style=3D"color:#066">42</span><span style=3D"co=
lor:#660">></span><span style=3D"color:#000"> ex</span><span style=3D"co=
lor:#660">;</span><span style=3D"color:#000"><br> std</span><s=
pan style=3D"color:#660">::</span><span style=3D"color:#000">cout </span><s=
pan style=3D"color:#660"><<</span><span style=3D"color:#000"> ex</spa=
n><span style=3D"color:#660">.</span><span style=3D"color:#000">value_of_42=
</span><span style=3D"color:#660"><<</span><span style=3D"color:#000=
"> std</span><span style=3D"color:#660">::</span><span style=3D"color:#000"=
>endl</span><span style=3D"color:#660">;</span><span style=3D"color:#000"> =
</span><span style=3D"color:#800">//prints 42</span><span style=3D"color:#0=
00"><br> </span><span style=3D"color:#008">return</span><span =
style=3D"color:#000"> </span><span style=3D"color:#066">0</span><span style=
=3D"color:#660">;</span><span style=3D"color:#000"><br></span><span style=
=3D"color:#660">}</span><span style=3D"color:#000"><br></span></div></code>=
</div><br>First off, I know this particular example wouldn't be very useful=
in practice. But it's useful as an example. Notice the nonstandard use of =
the <span style=3D"font-family:courier new,monospace">using</span> keyword.=
This keyword works very well here, reading as "Declare <span style=3D"font=
-family:courier new,monospace">int value</span>, <span style=3D"font-family=
:courier new,monospace">using</span> a name determined by <span style=3D"fo=
nt-family:courier new,monospace">("value_of_" + n)</span>."<br><br>The word=
<span style=3D"font-family:courier new,monospace">value</span> here is jus=
t the name of the variable used within the class, which isn't visible outsi=
de the class. This is necessary because within the class the value of <span=
style=3D"font-family:courier new,monospace">n</span> could be anything, me=
aning the external name could also be one of many different things.<br><br>=
This could basically be used for having a class with any number of members =
determined by template parameters, which as of now (AFAIK) is not possible.=
One potential use this would have is making tuples look cleaner. Instead o=
f using <span style=3D"font-family:courier new,monospace">std::get<2>=
(aTuple)</span>, you could use something like <span style=3D"font-family:co=
urier new,monospace">aTuple.value2</span>.<br><br>A slightly more complex e=
xample making use of inheritance to create multiple members with dynamic na=
mes:<br><br><div style=3D"background-color:rgb(250,250,250);border-color:rg=
b(187,187,187);border-style:solid;border-width:1px;word-wrap:break-word"><c=
ode><div><span style=3D"color:#800">#include</span><span style=3D"color:#00=
0"> </span><span style=3D"color:#080"><iostream></span><span style=3D=
"color:#000"><br> <br></span><span style=3D"color:#008">template</span=
><span style=3D"color:#000"> </span><span style=3D"color:#660"><</span><=
span style=3D"color:#008">int</span><span style=3D"color:#000"> </span><spa=
n style=3D"color:#606">MaxValue</span><span style=3D"color:#660">></span=
><span style=3D"color:#000"><br></span><span style=3D"color:#008">struct</s=
pan><span style=3D"color:#000"> </span><span style=3D"color:#606">ListOfVal=
ues</span><span style=3D"color:#000"> </span><span style=3D"color:#660">:</=
span><span style=3D"color:#000"> </span><span style=3D"color:#008">public</=
span><span style=3D"color:#000"> </span><span style=3D"color:#606">ListOfVa=
lues</span><span style=3D"color:#660"><</span><span style=3D"color:#606"=
>MaxValue</span><span style=3D"color:#000"> </span><span style=3D"color:#66=
0">-</span><span style=3D"color:#000"> </span><span style=3D"color:#066">1<=
/span><span style=3D"color:#660">></span><span style=3D"color:#000"><br>=
</span><span style=3D"color:#660">{</span><span style=3D"color:#000"><br>&n=
bsp; </span><span style=3D"color:#008">const</span><span style=3D"co=
lor:#000"> </span><span style=3D"color:#008">int</span><span style=3D"color=
:#000"> value </span><span style=3D"color:#008">using</span><span style=3D"=
color:#000"> </span><span style=3D"color:#660">(</span><span style=3D"color=
:#080">"value_of_"</span><span style=3D"color:#000"> </span><span style=3D"=
color:#660">+</span><span style=3D"color:#000"> </span><span style=3D"color=
:#606">MaxValue</span><span style=3D"color:#660">)</span><span style=3D"col=
or:#000"> </span><span style=3D"color:#660">=3D</span><span style=3D"color:=
#000"> </span><span style=3D"color:#606">MaxValue</span><span style=3D"colo=
r:#660">;</span><span style=3D"color:#000"><br></span><span style=3D"color:=
#660">}</span><span style=3D"color:#000"><br> <br></span><span style=
=3D"color:#008">template</span><span style=3D"color:#000"> </span><span sty=
le=3D"color:#660"><></span><span style=3D"color:#000"><br></span><spa=
n style=3D"color:#008">struct</span><span style=3D"color:#000"> </span><spa=
n style=3D"color:#606">ListOfValues</span><span style=3D"color:#660"><</=
span><span style=3D"color:#066">0</span><span style=3D"color:#660">></sp=
an><span style=3D"color:#000"><br></span><span style=3D"color:#660">{</span=
><span style=3D"color:#000"><br> </span><span style=3D"color:#=
008">const</span><span style=3D"color:#000"> </span><span style=3D"color:#0=
08">int</span><span style=3D"color:#000"> value_of_0 </span><span style=3D"=
color:#660">=3D</span><span style=3D"color:#000"> </span><span style=3D"col=
or:#066">0</span><span style=3D"color:#660">;</span><span style=3D"color:#0=
00"><br></span><span style=3D"color:#660">}</span><span style=3D"color:#000=
"><br> <br></span><span style=3D"color:#008">int</span><span style=3D"=
color:#000"> main</span><span style=3D"color:#660">(</span><span style=3D"c=
olor:#008">int</span><span style=3D"color:#000"> argc</span><span style=3D"=
color:#660">,</span><span style=3D"color:#000"> </span><span style=3D"color=
:#008">char</span><span style=3D"color:#000"> </span><span style=3D"color:#=
660">*</span><span style=3D"color:#000">argv</span><span style=3D"color:#66=
0">[])</span><span style=3D"color:#000"><br></span><span style=3D"color:#66=
0">{</span><span style=3D"color:#000"><br> </span><span style=
=3D"color:#606">ListOfValues</span><span style=3D"color:#660"><</span><s=
pan style=3D"color:#066">3</span><span style=3D"color:#660">></span><spa=
n style=3D"color:#000"> list</span><span style=3D"color:#660">;</span><span=
style=3D"color:#000"><br> std</span><span style=3D"color:#660=
">::</span><span style=3D"color:#000">cout </span><span style=3D"color:#660=
"><<</span><span style=3D"color:#000"> list</span><span style=3D"colo=
r:#660">.</span><span style=3D"color:#000">value_of_0 </span><span style=3D=
"color:#660"><<</span><span style=3D"color:#000"> list</span><span st=
yle=3D"color:#660">.</span><span style=3D"color:#000">value_of_1 </span><sp=
an style=3D"color:#660"><<</span><span style=3D"color:#000"> list</sp=
an><span style=3D"color:#660">.</span><span style=3D"color:#000">value_of_2=
</span><span style=3D"color:#660"><<</span><span style=3D"color:#000=
"> list</span><span style=3D"color:#660">.</span><span style=3D"color:#000"=
>value_of_3 </span><span style=3D"color:#660"><<</span><span style=3D=
"color:#000"> std</span><span style=3D"color:#660">::</span><span style=3D"=
color:#000">endl</span><span style=3D"color:#660">;</span><span style=3D"co=
lor:#000"> </span><span style=3D"color:#800">//prints 0123</span><span styl=
e=3D"color:#000"><br> </span><span style=3D"color:#008">return=
</span><span style=3D"color:#000"> </span><span style=3D"color:#066">0</spa=
n><span style=3D"color:#660">;</span><span style=3D"color:#000"><br></span>=
<span style=3D"color:#660">}</span><span style=3D"color:#000"><br></span></=
div></code></div></div></blockquote></div></div></blockquote></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_61_30142530.1430915884023--
------=_Part_60_436741311.1430915884019--
.
Author: hun.nemethpeter@gmail.com
Date: Wed, 6 May 2015 06:02:03 -0700 (PDT)
Raw View
------=_Part_317_1292292168.1430917323356
Content-Type: multipart/alternative;
boundary="----=_Part_318_2052345465.1430917323356"
------=_Part_318_2052345465.1430917323356
Content-Type: text/plain; charset=UTF-8
As I saw you can hack any kind of syntax to clang. But I am not sure what
kind of different semantics you want. Can you give me an example for that
compile-time-for with your proposed syntax?
Peter
On Wednesday, May 6, 2015 at 2:38:04 PM UTC+2, Igor Baidiuk wrote:
>
> Just curious. Is it possible for CLang to have different semantics on some
> block?
> Like, [[macro]] { ... different semantics go here ... };
> This would allow to use more convenient syntax, without those strange
> #<for>
> Or, maybe, have #<( compile-time manipulation goes here )>
>
> I thought about CT reflection in C++ similar to one in Nemerle, where
> compile-time macros were special kind of functions which produced AST nodes
> instead of ordinary values, and some kind of quasi-quotation syntax inside
> macro blocks to easily specify pieces of code.
>
>
>
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
------=_Part_318_2052345465.1430917323356
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">As I saw you can hack any kind of syntax to clang. But I a=
m not sure what kind of different semantics you want. Can you give me =
an example for that compile-time-for with your proposed syntax?<div><div><b=
r></div><div>Peter<br><br>On Wednesday, May 6, 2015 at 2:38:04 PM UTC+2, Ig=
or Baidiuk wrote:<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">Just curious. Is it possible for CLang to have different semantics on s=
ome block?<br>Like, [[macro]] { ... different semantics go here ... };<br>T=
his would allow to use more convenient syntax, without those strange #<f=
or><br>Or, maybe, have #<( compile-time manipulation goes here )><=
br><br>I thought about CT reflection in C++ similar to one in Nemerle, wher=
e compile-time macros were special kind of functions which produced AST nod=
es instead of ordinary values, and some kind of quasi-quotation syntax insi=
de macro blocks to easily specify pieces of code.<br><br><br></div></blockq=
uote></div></div></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_318_2052345465.1430917323356--
------=_Part_317_1292292168.1430917323356--
.
Author: Igor Baidiuk <target.san@gmail.com>
Date: Wed, 6 May 2015 06:05:53 -0700 (PDT)
Raw View
------=_Part_102_1078014110.1430917553318
Content-Type: multipart/alternative;
boundary="----=_Part_103_2011100678.1430917553318"
------=_Part_103_2011100678.1430917553318
Content-Type: text/plain; charset=UTF-8
Here:
https://groups.google.com/a/isocpp.org/d/topic/std-proposals/p6Rz7srXaKk/discussion
Differs from your proposal mostly in using wrap block, where types, AST
pieces etc. become ordinary data, and control statements look pretty much
the same.
On Wednesday, May 6, 2015 at 4:02:03 PM UTC+3, hun.nem...@gmail.com wrote:
>
> As I saw you can hack any kind of syntax to clang. But I am not sure what
> kind of different semantics you want. Can you give me an example for that
> compile-time-for with your proposed syntax?
>
> Peter
>
> On Wednesday, May 6, 2015 at 2:38:04 PM UTC+2, Igor Baidiuk wrote:
>>
>> Just curious. Is it possible for CLang to have different semantics on
>> some block?
>> Like, [[macro]] { ... different semantics go here ... };
>> This would allow to use more convenient syntax, without those strange
>> #<for>
>> Or, maybe, have #<( compile-time manipulation goes here )>
>>
>> I thought about CT reflection in C++ similar to one in Nemerle, where
>> compile-time macros were special kind of functions which produced AST nodes
>> instead of ordinary values, and some kind of quasi-quotation syntax inside
>> macro blocks to easily specify pieces of code.
>>
>>
>>
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
------=_Part_103_2011100678.1430917553318
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Here: https://groups.google.com/a/isocpp.org/d/topic/std-p=
roposals/p6Rz7srXaKk/discussion<br>Differs from your proposal mostly in usi=
ng wrap block, where types, AST pieces etc. become ordinary data, and contr=
ol statements look pretty much the same.<br><br>On Wednesday, May 6, 2015 a=
t 4:02:03 PM UTC+3, hun.nem...@gmail.com wrote:<blockquote class=3D"gmail_q=
uote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;pad=
ding-left: 1ex;"><div dir=3D"ltr">As I saw you can hack any kind of syntax =
to clang. But I am not sure what kind of different semantics you want.=
Can you give me an example for that compile-time-for with your proposed sy=
ntax?<div><div><br></div><div>Peter<br><br>On Wednesday, May 6, 2015 at 2:3=
8:04 PM UTC+2, Igor Baidiuk 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">Just curious. Is it possible for CLang to have different =
semantics on some block?<br>Like, [[macro]] { ... different semantics go he=
re ... };<br>This would allow to use more convenient syntax, without those =
strange #<for><br>Or, maybe, have #<( compile-time manipulation go=
es here )><br><br>I thought about CT reflection in C++ similar to one in=
Nemerle, where compile-time macros were special kind of functions which pr=
oduced AST nodes instead of ordinary values, and some kind of quasi-quotati=
on syntax inside macro blocks to easily specify pieces of code.<br><br><br>=
</div></blockquote></div></div></div></blockquote></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_103_2011100678.1430917553318--
------=_Part_102_1078014110.1430917553318--
.