Topic: operator typename
Author: MJanes <max.jns@gmail.com>
Date: Sun, 22 Sep 2013 06:12:42 -0700 (PDT)
Raw View
------=_Part_2898_22190770.1379855562070
Content-Type: text/plain; charset=ISO-8859-1
the aim is to "implicitly convert" an object of literal type into a
type encoding some compile-time state. Consider,
// a class template exposing the integer N, ala integral_constant,
// or any other non-type template argument
template<unsigned long long N> struct C{ ... };
// a literal type
struct B
{
// the implicitly constexpr, implicitly deleted ( in the sense
// that no body is allowed ) typename "conversion" function
operator typename() -> C< this->N >;
// the state
unsigned long long N;
};
now, the typename operator would be "invoked" whenever a constexpr
object appears where a type-id would be expected, or when a
functional ( typename(b) ) notation is used. Moreover, the compiler
would provide typename conversions for foundamental types ( at least,
those allowed as non-type template arguments ), eg typename(5) == std:
:integral_constant<int,5>, etc...
For example:
// given some class template:
template<class T> struct A{ ... };
// given a user defined literal, implemented the obvious way
constexpr B operator"" _b( unsigned long long n );
A<1> a1; // A<std::integral_constant<int,1>
A<2_b> a2; // A<C<2>>
constexpr B b{4};
typename(b) c; // a C<4>
// etc...
if I'm not missing something ( and I probably do, note this is just
at the brainstorming level ... ), this would allow us
1) generalize non-type template parameters
2) ... without the usual non-type t.p. caveats ( eg template template
params ... ), no more non-types in library interfaces
3) unlimited placeholders ( 1_,2_,... ), or the like
4) no more syntactical variants to support types and non-types ( eg
some_templ<integral_constant<int,N>> VS some_templ_<N> )
5) generically associate type-data to object instances ( even a non-
literal type could have a "compile time value", in some sensible
meaning, couldn't it ? )
thoughts ?
--
---
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_2898_22190770.1379855562070
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">the aim is to "implicitly convert" an object of literal ty=
pe into a<br>type encoding some compile-time state. Consider,<br><br><div c=
lass=3D"prettyprint" style=3D"background-color: rgb(250, 250, 250); border-=
color: rgb(187, 187, 187); border-style: solid; border-width: 1px; word-wra=
p: break-word;"><code class=3D"prettyprint"><div class=3D"subprettyprint"><=
span style=3D"color: #800;" class=3D"styled-by-prettify">// a class templat=
e exposing the integer N, ala integral_constant,</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #800=
;" class=3D"styled-by-prettify">// or any other non-type template argument<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span>=
<span style=3D"color: #008;" class=3D"styled-by-prettify">template</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify"><</span><span st=
yle=3D"color: #008;" class=3D"styled-by-prettify">unsigned</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"colo=
r: #008;" class=3D"styled-by-prettify">long</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">long</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> N</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: #008;" class=3D"styled-by-prettify">struc=
t</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> C</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">{</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">...</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">};</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"><br><br></span><span style=3D"color: #800;" class=3D"styled=
-by-prettify">// a literal type</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"> B<br></span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">{</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><b=
r> </span><span style=3D"color: #800;" class=3D"styled-by-pret=
tify">// the implicitly constexpr, implicitly deleted ( in the sense</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"><br> =
</span><span style=3D"color: #800;" class=3D"styled-by-prettify">// =
that no body is allowed ) typename "conversion" function</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br> </span><sp=
an style=3D"color: #008;" class=3D"styled-by-prettify">operator</span><span=
style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D=
"color: #008;" class=3D"styled-by-prettify">typename</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">()</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">-></span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"> C</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify"><</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">thi=
s</span><span style=3D"color: #660;" class=3D"styled-by-prettify">-></sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify">N </span><span=
style=3D"color: #660;" class=3D"styled-by-prettify">>;</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"><br><br> </spa=
n><span style=3D"color: #800;" class=3D"styled-by-prettify">// the state</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"><br> &n=
bsp; </span><span style=3D"color: #008;" class=3D"styled-by-prettify">unsig=
ned</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span style=3D"color: #008;" class=3D"styled-by-prettify">long</span><span=
style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D=
"color: #008;" class=3D"styled-by-prettify">long</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> N</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"style=
d-by-prettify">};</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"><br></span></div></code></div><br>now, the typename operator would b=
e "invoked" whenever a constexpr<br>object appears where a type-id would be=
expected, or when a<br>functional ( typename(b) ) notation is used. Moreov=
er, the compiler<br>would provide typename conversions for foundamental typ=
es ( at least,<br>those allowed as non-type template arguments ), eg typena=
me(5) =3D=3D std:<br>:integral_constant<int,5>, etc...<br><br>For exa=
mple:<br><br><div class=3D"prettyprint" style=3D"background-color: rgb(250,=
250, 250); border-color: rgb(187, 187, 187); border-style: solid; border-w=
idth: 1px; word-wrap: break-word;"><code class=3D"prettyprint"><div class=
=3D"subprettyprint"><span style=3D"color: #800;" class=3D"styled-by-prettif=
y">// given some class template:</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br></span><span style=3D"color: #008;" class=3D"st=
yled-by-prettify">template</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify"><</span><span style=3D"color: #008;" class=3D"styled-by-=
prettify">class</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> T</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: #008;" class=3D"styled-by-prettify">struct</span><span=
style=3D"color: #000;" class=3D"styled-by-prettify"> A</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: #660;" =
class=3D"styled-by-prettify">...</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">};</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"><br><br></span><span style=3D"color: #800;" class=3D"styled-by-prett=
ify">// given a user defined literal, implemented the obvious way</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span sty=
le=3D"color: #008;" class=3D"styled-by-prettify">constexpr</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"> B </span><span style=3D"co=
lor: #008;" class=3D"styled-by-prettify">operator</span><span style=3D"colo=
r: #080;" class=3D"styled-by-prettify">""</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"> _b</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">(</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-pret=
tify">unsigned</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">long<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><sp=
an style=3D"color: #008;" class=3D"styled-by-prettify">long</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"> n </span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">);</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"><br><br>A</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify"><</span><span style=3D"color: #066;" cl=
ass=3D"styled-by-prettify">1</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">></span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> a1</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </s=
pan><span style=3D"color: #800;" class=3D"styled-by-prettify">// A<std::=
integral_constant<int,1></span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"><br>A</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify"><</span><span style=3D"color: #066;" class=3D"styled-by-p=
rettify">2</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
_b</span><span style=3D"color: #660;" class=3D"styled-by-prettify">></sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"> a2</span><spa=
n 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=
: #800;" class=3D"styled-by-prettify">// A<C<2>></span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"><br><br></span><span styl=
e=3D"color: #008;" class=3D"styled-by-prettify">constexpr</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> B b</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">{</span><span style=3D"color: #066=
;" class=3D"styled-by-prettify">4</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">};</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"><br></span><span style=3D"color: #008;" class=3D"styled-by-=
prettify">typename</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">(</span><span style=3D"color: #000;" class=3D"styled-by-prettify">b=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">)</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"> c</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #800;"=
class=3D"styled-by-prettify">// a C<4></span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"><br><br></span><span style=3D"color: #80=
0;" class=3D"styled-by-prettify">// etc...</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"><br></span></div></code></div><br>if I'm no=
t missing something ( and I probably do, note this is just<br>at the brains=
torming level ... ), this would allow us<br><br>1) generalize non-type temp=
late parameters<br><br>2) ... without the usual non-type t.p. caveats ( eg =
template template<br> params ... ), no more non-types in =
library interfaces<br><br>3) unlimited placeholders ( 1_,2_,... ), or the l=
ike<br><br>4) no more syntactical variants to support types and non-types (=
eg<br> some_templ<integral_constant<int,N>> =
VS some_templ_<N> )<br><br>5) generically associate type-data to obje=
ct instances ( even a non-<br> literal type could have a =
"compile time value", in some sensible<br> meaning, could=
n't it ? )<br><br>thoughts ?<br><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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<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_2898_22190770.1379855562070--
.
Author: inkwizytoryankes@gmail.com
Date: Sun, 22 Sep 2013 07:43:27 -0700 (PDT)
Raw View
------=_Part_156_23768382.1379861007998
Content-Type: text/plain; charset=ISO-8859-1
This will never work because you cant modify or add new types on runtime,
and you code do it (e.g. `C<this->N>`, even if you try it in constexpr).
Only thing that C++ and is similar to this, is:
`C<some_type::constexpr_static_object.N>`.
Unlimited placeholders are already possible in C++11:
template<char... I>
constexpr PH<I...> operator"" _ph () { return {}; }
On Sunday, September 22, 2013 3:12:42 PM UTC+2, MJanes wrote:
>
> the aim is to "implicitly convert" an object of literal type into a
> type encoding some compile-time state. Consider,
>
> // a class template exposing the integer N, ala integral_constant,
> // or any other non-type template argument
> template<unsigned long long N> struct C{ ... };
>
> // a literal type
> struct B
> {
> // the implicitly constexpr, implicitly deleted ( in the sense
> // that no body is allowed ) typename "conversion" function
> operator typename() -> C< this->N >;
>
> // the state
> unsigned long long N;
> };
>
> now, the typename operator would be "invoked" whenever a constexpr
> object appears where a type-id would be expected, or when a
> functional ( typename(b) ) notation is used. Moreover, the compiler
> would provide typename conversions for foundamental types ( at least,
> those allowed as non-type template arguments ), eg typename(5) == std:
> :integral_constant<int,5>, etc...
>
> For example:
>
> // given some class template:
> template<class T> struct A{ ... };
>
> // given a user defined literal, implemented the obvious way
> constexpr B operator"" _b( unsigned long long n );
>
> A<1> a1; // A<std::integral_constant<int,1>
> A<2_b> a2; // A<C<2>>
>
> constexpr B b{4};
> typename(b) c; // a C<4>
>
> // etc...
>
> if I'm not missing something ( and I probably do, note this is just
> at the brainstorming level ... ), this would allow us
>
> 1) generalize non-type template parameters
>
> 2) ... without the usual non-type t.p. caveats ( eg template template
> params ... ), no more non-types in library interfaces
>
> 3) unlimited placeholders ( 1_,2_,... ), or the like
>
> 4) no more syntactical variants to support types and non-types ( eg
> some_templ<integral_constant<int,N>> VS some_templ_<N> )
>
> 5) generically associate type-data to object instances ( even a non-
> literal type could have a "compile time value", in some sensible
> meaning, couldn't it ? )
>
> thoughts ?
>
>
--
---
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_156_23768382.1379861007998
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">This will never work because you cant modify or add new ty=
pes on runtime, and you code do it (e.g. `<code><span style=3D"color:#000">=
C</span><span style=3D"color:#660"><</span><span style=3D"color:#000"></=
span></code>this->N>`, even if you try it in constexpr).<br>Only thin=
g that C++ and is similar to this, is: `C<some_type::constexpr_static_ob=
ject.N>`.<br><br>Unlimited placeholders are already possible in C++11:<b=
r><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"subpretty=
print"><span style=3D"color: #008;" class=3D"styled-by-prettify">template</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify"><</span><=
span style=3D"color: #008;" class=3D"styled-by-prettify">char</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">...</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"> I</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">></span><span style=3D"color: #000;"=
class=3D"styled-by-prettify"><br></span><code><span style=3D"color:#008"><=
span style=3D"color: #008;" class=3D"styled-by-prettify">constexpr</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"> PH</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify"><</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify">I</span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">...></span></span><span style=3D"color=
:#000"><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span></=
span></code><code><span style=3D"color:#000"></span><span style=3D"color:#0=
08"><span style=3D"color: #008;" class=3D"styled-by-prettify">operator</spa=
n></span><span style=3D"color:#080"><span style=3D"color: #080;" class=3D"s=
tyled-by-prettify">""</span></span><span style=3D"color:#000"><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> _ph </span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">()</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">{</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-pre=
ttify">return</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">{};</s=
pan><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-by-prettify"><br></span></span></code></div>=
</code></div><br><br><br><br><br>On Sunday, September 22, 2013 3:12:42 PM U=
TC+2, MJanes wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;mar=
gin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D=
"ltr">the aim is to "implicitly convert" an object of literal type into a<b=
r>type encoding some compile-time state. Consider,<br><br><div style=3D"bac=
kground-color:rgb(250,250,250);border-color:rgb(187,187,187);border-style:s=
olid;border-width:1px;word-wrap:break-word"><code><div><span style=3D"color=
:#800">// a class template exposing the integer N, ala integral_constant,</=
span><span style=3D"color:#000"><br></span><span style=3D"color:#800">// or=
any other non-type template argument</span><span style=3D"color:#000"><br>=
</span><span style=3D"color:#008">template</span><span style=3D"color:#660"=
><</span><span style=3D"color:#008">unsigned</span><span style=3D"color:=
#000"> </span><span style=3D"color:#008">long</span><span style=3D"color:#0=
00"> </span><span style=3D"color:#008">long</span><span style=3D"color:#000=
"> N</span><span style=3D"color:#660">></span><span style=3D"color:#000"=
> </span><span style=3D"color:#008">struct</span><span style=3D"color:#000"=
> C</span><span style=3D"color:#660">{</span><span style=3D"color:#000"> </=
span><span style=3D"color:#660">...</span><span style=3D"color:#000"> </spa=
n><span style=3D"color:#660">};</span><span style=3D"color:#000"><br><br></=
span><span style=3D"color:#800">// a literal type</span><span style=3D"colo=
r:#000"><br></span><span style=3D"color:#008">struct</span><span style=3D"c=
olor:#000"> B<br></span><span style=3D"color:#660">{</span><span style=3D"c=
olor:#000"><br> </span><span style=3D"color:#800">// the impli=
citly constexpr, implicitly deleted ( in the sense</span><span style=3D"col=
or:#000"><br> </span><span style=3D"color:#800">// that =
no body is allowed ) typename "conversion" function</span><span style=3D"co=
lor:#000"><br> </span><span style=3D"color:#008">operator</spa=
n><span style=3D"color:#000"> </span><span style=3D"color:#008">typename</s=
pan><span style=3D"color:#660">()</span><span style=3D"color:#000"> </span>=
<span style=3D"color:#660">-></span><span style=3D"color:#000"> C</span>=
<span style=3D"color:#660"><</span><span style=3D"color:#000"> </span><s=
pan style=3D"color:#008">this</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"colo=
r:#800">// the state</span><span style=3D"color:#000"><br> </s=
pan><span style=3D"color:#008">unsigned</span><span style=3D"color:#000"> <=
/span><span style=3D"color:#008">long</span><span style=3D"color:#000"> </s=
pan><span style=3D"color:#008">long</span><span style=3D"color:#000"> N</sp=
an><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>now, the typename operator would be "invoked" whenev=
er a constexpr<br>object appears where a type-id would be expected, or when=
a<br>functional ( typename(b) ) notation is used. Moreover, the compiler<b=
r>would provide typename conversions for foundamental types ( at least,<br>=
those allowed as non-type template arguments ), eg typename(5) =3D=3D std:<=
br>:integral_constant<int,5>, etc...<br><br>For example:<br><br><div =
style=3D"background-color:rgb(250,250,250);border-color:rgb(187,187,187);bo=
rder-style:solid;border-width:1px;word-wrap:break-word"><code><div><span st=
yle=3D"color:#800">// given some class template:</span><span style=3D"color=
:#000"><br></span><span style=3D"color:#008">template</span><span style=3D"=
color:#660"><</span><span style=3D"color:#008">class</span><span style=
=3D"color:#000"> T</span><span style=3D"color:#660">></span><span style=
=3D"color:#000"> </span><span style=3D"color:#008">struct</span><span style=
=3D"color:#000"> A</span><span style=3D"color:#660">{</span><span style=3D"=
color:#000"> </span><span style=3D"color:#660">...</span><span style=3D"col=
or:#000"> </span><span style=3D"color:#660">};</span><span style=3D"color:#=
000"><br><br></span><span style=3D"color:#800">// given a user defined lite=
ral, implemented the obvious way</span><span style=3D"color:#000"><br></spa=
n><span style=3D"color:#008">constexpr</span><span style=3D"color:#000"> B =
</span><span style=3D"color:#008">operator</span><span style=3D"color:#080"=
>""</span><span style=3D"color:#000"> _b</span><span style=3D"color:#660">(=
</span><span style=3D"color:#000"> </span><span style=3D"color:#008">unsign=
ed</span><span style=3D"color:#000"> </span><span style=3D"color:#008">long=
</span><span style=3D"color:#000"> </span><span style=3D"color:#008">long</=
span><span style=3D"color:#000"> n </span><span style=3D"color:#660">);</sp=
an><span style=3D"color:#000"><br><br>A</span><span style=3D"color:#660">&l=
t;</span><span style=3D"color:#066">1</span><span style=3D"color:#660">>=
</span><span style=3D"color:#000"> a1</span><span style=3D"color:#660">;</s=
pan><span style=3D"color:#000"> </span><span style=3D"color:#800">// A<s=
td::integral_constant<int,<wbr>1></span><span style=3D"color:#000"><b=
r>A</span><span style=3D"color:#660"><</span><span style=3D"color:#066">=
2</span><span style=3D"color:#000">_b</span><span style=3D"color:#660">>=
</span><span style=3D"color:#000"> a2</span><span style=3D"color:#660">;</s=
pan><span style=3D"color:#000"> </span><span style=3D"color:#800">// A<C=
<2>></span><span style=3D"color:#000"><br><br></span><span style=
=3D"color:#008">constexpr</span><span style=3D"color:#000"> B b</span><span=
style=3D"color:#660">{</span><span style=3D"color:#066">4</span><span styl=
e=3D"color:#660">};</span><span style=3D"color:#000"><br></span><span style=
=3D"color:#008">typename</span><span style=3D"color:#660">(</span><span sty=
le=3D"color:#000">b</span><span style=3D"color:#660">)</span><span style=3D=
"color:#000"> c</span><span style=3D"color:#660">;</span><span style=3D"col=
or:#000"> </span><span style=3D"color:#800">// a C<4></span><span sty=
le=3D"color:#000"><br><br></span><span style=3D"color:#800">// etc...</span=
><span style=3D"color:#000"><br></span></div></code></div><br>if I'm not mi=
ssing something ( and I probably do, note this is just<br>at the brainstorm=
ing level ... ), this would allow us<br><br>1) generalize non-type template=
parameters<br><br>2) ... without the usual non-type t.p. caveats ( eg temp=
late template<br> params ... ), no more non-types in libr=
ary interfaces<br><br>3) unlimited placeholders ( 1_,2_,... ), or the like<=
br><br>4) no more syntactical variants to support types and non-types ( eg<=
br> some_templ<integral_constant<<wbr>int,N>>=
VS some_templ_<N> )<br><br>5) generically associate type-data to obj=
ect instances ( even a non-<br> literal type could have a=
"compile time value", in some sensible<br> meaning, coul=
dn't it ? )<br><br>thoughts ?<br><br></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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<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_156_23768382.1379861007998--
.
Author: MJanes <max.jns@gmail.com>
Date: Sun, 22 Sep 2013 08:24:34 -0700 (PDT)
Raw View
------=_Part_223_31534204.1379863474811
Content-Type: text/plain; charset=ISO-8859-1
> This will never work because you cant modify or add new types on runtime,
> and you code do it (e.g. `C<this->N>`, even if you try it in constexpr).
>
actually, my code does nothing being not valid c++ ( obviously, special
rules about the appeareance of 'this' should apply in order for such code
to have a meaning ) and no, no type would be "created" at runtime; it
should be the same situation as in the following (as far as I can tell,
legal) code:
template< int N > struct A {};
struct B { int N; constexpr auto f() -> int { return this->N; } };
constexpr B b{1};
A<b.f()> a;
the typename operator would do something essentially similar ... unless
there are other technical reasons why the syntax above could not be
parsed/interpreted correctly, of course
Unlimited placeholders are already possible in C++11:
>
clearly, I was not speaking of object placeholders, but type placeholders (
as those in boost::mpl ) ...
--
---
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_223_31534204.1379863474811
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><blockquote class=3D"gmail_quote" style=3D"margin: 0;m=
argin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=
=3D"ltr">This will never work because you cant modify or add new types on r=
untime, and you code do it (e.g. `<code><span style=3D"color:#000">C</span>=
<span style=3D"color:#660"><</span><span style=3D"color:#000"></span></c=
ode>this->N>`, even if you try it in constexpr).<br></div></blockquot=
e><div><br>actually, my code does nothing being not valid c++ ( obviously, =
special rules about the appeareance of 'this' should apply in order for suc=
h code to have a meaning ) and no, no type would be "created" at runtime; i=
t should be the same situation as in the following (as far as I can tell, l=
egal) code:<br><br><div class=3D"prettyprint" style=3D"background-color: rg=
b(250, 250, 250); border-color: rgb(187, 187, 187); border-style: solid; bo=
rder-width: 1px; word-wrap: break-word;"><code class=3D"prettyprint"><div c=
lass=3D"subprettyprint"><span style=3D"color: #008;" class=3D"styled-by-pre=
ttify">template</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify"><</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;" class=3D"styled-by-prettify"> N </span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">></span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #008;" class=3D"styled-by-prettify">struct</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> A </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"styled=
-by-prettify">struct</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"> B </span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">{</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </spa=
n><span style=3D"color: #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;" class=3D"styled-by-prettify">;</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" =
class=3D"styled-by-prettify">constexpr</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"s=
tyled-by-prettify">auto</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"> f</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">()</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-by-prettify"> </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"> </span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">{</span><span style=3D"color: #000;"=
class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D=
"styled-by-prettify">return</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-pr=
ettify">this</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">-></span><span style=3D"color: #000;" class=3D"styled-by-prettify">N</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><spa=
n 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-by-prettify"> </span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">};</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"><br><br></span><span style=3D"color: #008;" class=3D"s=
tyled-by-prettify">constexpr</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> B b</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">{</span><span style=3D"color: #066;" class=3D"styled-by-prettif=
y">1</span><span style=3D"color: #660;" class=3D"styled-by-prettify">};</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>A</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify"><</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify">b</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">.</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify">f</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">()></span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"> a</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></div></code></div><br>the typename operator would do somethi=
ng essentially similar ... unless there are other technical reasons why the=
syntax above could not be parsed/interpreted correctly, of course<br><br><=
/div><blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8e=
x;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr">Unlimite=
d placeholders are already possible in C++11:</div></blockquote><div><br>cl=
early, I was not speaking of object placeholders, but type placeholders ( a=
s those in boost::mpl ) ...<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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<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_223_31534204.1379863474811--
.
Author: inkwizytoryankes@gmail.com
Date: Sun, 22 Sep 2013 08:45:20 -0700 (PDT)
Raw View
------=_Part_123_19685318.1379864720068
Content-Type: text/plain; charset=ISO-8859-1
But `this->N` change `B` not `A`. Templates can use result of constexpr but
contexpr cant modify templates in that way because it have same limitation
as normal functions.
I dont get this type palceholders, what will be difference to:
template<int I>
struct PH {};
using AA = A<PH<0>, FOO, PH<2>>;
using BB = templ_replace<AA, PH<0>, BAR>; //equal A<BAR, FOO, PH<2>>
On Sunday, September 22, 2013 5:24:34 PM UTC+2, MJanes wrote:
>
>
> This will never work because you cant modify or add new types on runtime,
>> and you code do it (e.g. `C<this->N>`, even if you try it in constexpr).
>>
>
> actually, my code does nothing being not valid c++ ( obviously, special
> rules about the appeareance of 'this' should apply in order for such code
> to have a meaning ) and no, no type would be "created" at runtime; it
> should be the same situation as in the following (as far as I can tell,
> legal) code:
>
> template< int N > struct A {};
> struct B { int N; constexpr auto f() -> int { return this->N; } };
>
> constexpr B b{1};
> A<b.f()> a;
>
> the typename operator would do something essentially similar ... unless
> there are other technical reasons why the syntax above could not be
> parsed/interpreted correctly, of course
>
> Unlimited placeholders are already possible in C++11:
>>
>
> clearly, I was not speaking of object placeholders, but type placeholders
> ( as those in boost::mpl ) ...
>
--
---
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_123_19685318.1379864720068
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">But `this->N` change `B` not `A`. Templates can use res=
ult of constexpr but contexpr cant modify templates in that way because it =
have same limitation as normal functions.<br><br>I dont get this type palce=
holders, what will be difference to:<br><div class=3D"prettyprint" style=3D=
"background-color: rgb(250, 250, 250); border-color: rgb(187, 187, 187); bo=
rder-style: solid; border-width: 1px; word-wrap: break-word;"><code class=
=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D"color: #008;"=
class=3D"styled-by-prettify">template</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify"><</span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">int</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> I</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">></span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"><br></span><span style=3D"color: #008;" class=3D"styled-by-prettify">str=
uct</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> PH </s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">{};</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"><br><br></span><span=
style=3D"color: #008;" class=3D"styled-by-prettify">using</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"> AA </span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"> A</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify"><</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify">PH</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify"><</span><span style=3D"color: #066;" class=3D"styled-by-pre=
ttify">0</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&g=
t;,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> FOO</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span=
style=3D"color: #000;" class=3D"styled-by-prettify"> PH</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify"><</span><span style=3D"co=
lor: #066;" class=3D"styled-by-prettify">2</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;" clas=
s=3D"styled-by-prettify">using</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"> BB </span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"> templ_replace</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify"><</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify">AA</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"> PH</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify"><</span><span st=
yle=3D"color: #066;" class=3D"styled-by-prettify">0</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">>,</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify"> BAR</span><span style=3D"color: #660;"=
class=3D"styled-by-prettify">>;</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"> </span><span style=3D"color: #800;" class=3D"styl=
ed-by-prettify">//equal A<BAR, FOO, PH<2>></span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"><br></span></div></code></div><=
br><br><br>On Sunday, September 22, 2013 5:24:34 PM UTC+2, MJanes wrote:<bl=
ockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border=
-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><br><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">This will never work because y=
ou cant modify or add new types on runtime, and you code do it (e.g. `<code=
><span style=3D"color:#000">C</span><span style=3D"color:#660"><</span><=
span style=3D"color:#000"></span></code>this->N>`, even if you try it=
in constexpr).<br></div></blockquote><div><br>actually, my code does nothi=
ng being not valid c++ ( obviously, special rules about the appeareance of =
'this' should apply in order for such code to have a meaning ) and no, no t=
ype would be "created" at runtime; it should be the same situation as in th=
e following (as far as I can tell, legal) code:<br><br><div style=3D"backgr=
ound-color:rgb(250,250,250);border-color:rgb(187,187,187);border-style:soli=
d;border-width:1px;word-wrap:break-word"><code><div><span style=3D"color:#0=
08">template</span><span style=3D"color:#660"><</span><span style=3D"col=
or:#000"> </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"> </span><span style=3D"color:#008">struct</span><span style=3D"color:=
#000"> A </span><span style=3D"color:#660">{};</span><span style=3D"color:#=
000"><br></span><span style=3D"color:#008">struct</span><span style=3D"colo=
r:#000"> B </span><span style=3D"color:#660">{</span><span style=3D"color:#=
000"> </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"> <=
/span><span style=3D"color:#008">constexpr</span><span style=3D"color:#000"=
> </span><span style=3D"color:#008">auto</span><span style=3D"color:#000"> =
f</span><span style=3D"color:#660">()</span><span style=3D"color:#000"> </s=
pan><span style=3D"color:#660">-></span><span style=3D"color:#000"> </sp=
an><span style=3D"color:#008">int</span><span style=3D"color:#000"> <=
/span><span style=3D"color:#660">{</span><span style=3D"color:#000"> </span=
><span style=3D"color:#008">return</span><span style=3D"color:#000"> </span=
><span style=3D"color:#008">this</span><span style=3D"color:#660">-></sp=
an><span style=3D"color:#000">N</span><span style=3D"color:#660">;</span><s=
pan style=3D"color:#000"> </span><span style=3D"color:#660">}</span><span s=
tyle=3D"color:#000"> </span><span style=3D"color:#660">};</span><span style=
=3D"color:#000"><br><br></span><span style=3D"color:#008">constexpr</span><=
span style=3D"color:#000"> B b</span><span style=3D"color:#660">{</span><sp=
an style=3D"color:#066">1</span><span style=3D"color:#660">};</span><span s=
tyle=3D"color:#000"><br>A</span><span style=3D"color:#660"><</span><span=
style=3D"color:#000">b</span><span style=3D"color:#660">.</span><span styl=
e=3D"color:#000">f</span><span style=3D"color:#660">()></span><span styl=
e=3D"color:#000"> a</span><span style=3D"color:#660">;</span><span style=3D=
"color:#000"><br></span></div></code></div><br>the typename operator would =
do something essentially similar ... unless there are other technical reaso=
ns why the syntax above could not be parsed/interpreted correctly, of cours=
e<br><br></div><blockquote class=3D"gmail_quote" style=3D"margin:0;margin-l=
eft:0.8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr">Unl=
imited placeholders are already possible in C++11:</div></blockquote><div><=
br>clearly, I was not speaking of object placeholders, but type placeholder=
s ( as those in boost::mpl ) ...<br></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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<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_123_19685318.1379864720068--
.
Author: MJanes <max.jns@gmail.com>
Date: Sun, 22 Sep 2013 09:07:56 -0700 (PDT)
Raw View
------=_Part_78_3674154.1379866076044
Content-Type: text/plain; charset=ISO-8859-1
Il giorno domenica 22 settembre 2013 17:45:20 UTC+2, inkwizyt...@gmail.com
ha scritto:
>
> But `this->N` change `B` not `A`. Templates can use result of constexpr
> but contexpr cant modify templates in that way because it have same
> limitation as normal functions.
>
>
again, clearly such a typename operator would not be a normal function, it
would not be a function at all. It resembles a conversion function due to
the obvious analogy, but it's just a shorthand syntax for, say
template< typename T > struct A {};
struct B
{
int N;
template< int M >
using typename_type = std::integral_constant<int,M>;
constexpr int typename_func() { return this->N; }
};
constexpr B b{1};
A< B::typename_type< b.typename_func() > > a; // operator typename would
allow writing just A<b>
again, I'm not sure at all if this is technically possible or not, but
still, your objections do not apply.
> I dont get this type palceholders, what will be difference to:
>
not much, just a matter of esthetics :) ( you could write A<0_,1_> instead
of the more verbose A<PH<0>,...> ). yes, this is a minor point actually
--
---
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_78_3674154.1379866076044
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><br>Il giorno domenica 22 settembre 2013 17:45:20 UTC+=
2, inkwizyt...@gmail.com ha scritto:<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">But `this->N` change `B` not `A`. Templates can u=
se result of constexpr but contexpr cant modify templates in that way becau=
se it have same limitation as normal functions.<br><br></div></blockquote><=
div><br>again, clearly such a typename operator would not be a normal funct=
ion, it would not be a function at all. It resembles a conversion function =
due to the obvious analogy, but it's just a shorthand syntax for, say<br><b=
r><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"subpretty=
print"><span style=3D"color: #008;" class=3D"styled-by-prettify">template</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify"><</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span styl=
e=3D"color: #008;" class=3D"styled-by-prettify">typename</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> T </span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">></span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" clas=
s=3D"styled-by-prettify">struct</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"> A </span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">{};</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"><br><br></span><span style=3D"color: #008;" class=3D"styled-by-prett=
ify">struct</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
> B<br></span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br> &=
nbsp; </span><span style=3D"color: #008;" class=3D"styled-by-prettify">int<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> N</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">;</span><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: #660;" class=3D"styled-by-prettify"><</span><span s=
tyle=3D"color: #000;" 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"> M </span><span style=3D"color: #660;" c=
lass=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">using</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> typename_type </span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">=3D</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"> std</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">::</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify">integral_constant</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify"><</span><span style=3D"color: #008;" class=3D"styled-b=
y-prettify">int</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify">M</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">>;</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br> &nb=
sp; </span><span style=3D"color: #008;" class=3D"styled-by-prettify">conste=
xpr</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;" class=3D"styled-by-prettify"> typename_func</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">()</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">{</span><span style=3D"color: #000;"=
class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D=
"styled-by-prettify">return</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-pr=
ettify">this</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">-></span><span style=3D"color: #000;" class=3D"styled-by-prettify">N</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><spa=
n 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-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></span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">constexpr</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> B b</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">{</span><span style=3D"color: #066;" class=3D"styled-by-p=
rettify">1</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
};</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>A</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify"><</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"> B</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">::</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify">typename_type</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify"><</span><span style=3D"color:=
#000;" class=3D"styled-by-prettify"> b</span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">.</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify">typename_func</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">()</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">></span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">></sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"> a</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: #=
800;" class=3D"styled-by-prettify">// operator typename would allow writing=
just A<b></span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"><br></span></div></code></div><br>again, I'm not sure at all if this =
is technically possible or not, but still, your objections do not apply.<br=
> </div><blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-le=
ft: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr">=
I dont get this type palceholders, what will be difference to:</div></block=
quote><div><br>not much, just a matter of esthetics :) ( you could write A&=
lt;0_,1_> instead of the more verbose A<PH<0>,...> ). yes, t=
his is a minor point actually <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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<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_78_3674154.1379866076044--
.
Author: MJanes <max.jns@gmail.com>
Date: Mon, 23 Sep 2013 00:54:13 -0700 (PDT)
Raw View
------=_Part_1415_15453439.1379922853443
Content-Type: text/plain; charset=ISO-8859-1
well, if the automatic interpretation as depicted above is hard or
techincally unviable, here is a possibly better ( more natural, much more
general ) alternative:
the operator typename would be declared as a usual member function
template, the only difference being that either a trailing return type or
no return type should be specified, that its unique argument should not
have a name, and that the function is implicitly constexpr.
so, given
template< t-param-list >
operator typename( type-id[1] ) -> type-id[2] { function-body }
such declaration would be interpreted as if replaced by the two following
hypothetical declarations:
// any attr-spec, decl-spec, cv, ref, etc.. in the original declaration
belongs to this function
template< t-param-list >
type-id[2] typename_func__() { function-body }
template< t-param-list >
using typename_type__ = type-id[1];
if no return type has been specified, std:::tuple would be assumed, with
elements being the types appearing in the t-param-list.
now, let T be the type to which these members belong and t an instance of
T, then 't.operator typename' would name the function typename_func__ and
'T::operator typename<t-arg-list>' would name the template alias
typename_type__.
Then, for each object t of type T appearing where a type-id is expected (
or for any explicit typename(t)/typename(T) ) the following replacement
occurs
....A<t>...
// --->
decl-spec type-id[2] r{ t.operator typename() }; // in the first enclosing
viable scope
....A< T::operator typename< get<0>(r), get<1>(r), ..., get< tuple_size<
decltype(r)>::value >(r) > >...
finally, as a concrete example ( recall the OP for the complete use cases ):
#include <tuple>
template<class T> struct A;
template<int N> struct C;
struct B
{
template< int N >
operator typename( C<N> ) { return std::make_tuple( this->n ); }
int n;
};
int main()
{
constexpr B b{4};
A<b> a;
}
// as if
int main()
{
constexpr B b{4};
constexpr std::tuple<int> r{ b.operator typename() };
A< B::operator typename< get<0>(r) > > a; // that is, A<C<4>>
}
note that this is a much more general solution, as it allows "nesting"
these generalized-non-type template parameters in operator typename
delcations ...
--
---
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_1415_15453439.1379922853443
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">well, if the automatic interpretation as depicted above is=
hard or techincally unviable, here is a possibly better ( more natural, mu=
ch more general ) alternative:<br><br>the operator typename would be declar=
ed as a usual member function template, the only difference being that eith=
er a trailing return type or no return type should be specified, that its u=
nique argument should not have a name, and that the function is implicitly =
constexpr.<br><br>so, given<br><br><div class=3D"prettyprint" style=3D"back=
ground-color: rgb(250, 250, 250); border-color: rgb(187, 187, 187); border-=
style: solid; border-width: 1px; word-wrap: break-word;"><code class=3D"pre=
ttyprint"><div class=3D"subprettyprint"><span style=3D"color: #008;" class=
=3D"styled-by-prettify">template</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify"><</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> t</span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">-</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
>param</span><span style=3D"color: #660;" class=3D"styled-by-prettify">-</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify">list </span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">></span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">operator</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #008;" class=3D"styled-by-prettify">typename</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> type</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">-</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify">id</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">[</span><span style=3D"color: #066;" class=3D"styled-by-prettify">1<=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">]</span><sp=
an 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-by-prettify"> </span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">-></span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> type</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">-</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify">id</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">[</span><span style=3D"color: #066;" class=3D"styled-by-prettify">2</span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">]</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">{</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">function</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">-</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify">body </span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">}</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
><br></span></div></code></div><br>such declaration would be interpreted as=
if replaced by the two following hypothetical declarations:<br><br><div cl=
ass=3D"prettyprint" style=3D"background-color: rgb(250, 250, 250); border-c=
olor: rgb(187, 187, 187); border-style: solid; border-width: 1px; word-wrap=
: break-word;"><code class=3D"prettyprint"><div class=3D"subprettyprint"><s=
pan style=3D"color: #800;" class=3D"styled-by-prettify">// any attr-spec, d=
ecl-spec, cv, ref, etc.. in the original declaration belongs to this functi=
on</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></sp=
an><span style=3D"color: #008;" class=3D"styled-by-prettify">template</span=
><span style=3D"color: #660;" class=3D"styled-by-prettify"><</span><span=
style=3D"color: #000;" class=3D"styled-by-prettify"> t</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">-</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify">param</span><span style=3D"color: #66=
0;" 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"s=
tyled-by-prettify">></span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"><br>type</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">-</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
">id</span><span style=3D"color: #660;" class=3D"styled-by-prettify">[</spa=
n><span style=3D"color: #066;" class=3D"styled-by-prettify">2</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">]</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> typename_func__</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">()</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: #008;" class=3D"style=
d-by-prettify">function</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">-</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy">body </span><span style=3D"color: #660;" class=3D"styled-by-prettify">}=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br></=
span><span style=3D"color: #008;" class=3D"styled-by-prettify">template</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify"><</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"> t</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">-</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify">param</span><span style=3D"color: #66=
0;" 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"s=
tyled-by-prettify">></span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"><br></span><span style=3D"color: #008;" class=3D"styled-by-pre=
ttify">using</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> typename_type__ </span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> type</span><span style=3D"color: #660;" class=3D"styled-by-prettify">-</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify">id</span><sp=
an style=3D"color: #660;" 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"styled-by-prettify"><br></span></div></code></div><br>if no retur=
n type has been specified, std:::tuple would be assumed, with elements bein=
g the types appearing in the t-param-list.<br><br>now, let T be the type to=
which these members belong and t an instance of T, then 't.operator typena=
me' would name the function typename_func__ and 'T::operator typename<t-=
arg-list>' would name the template alias typename_type__.<br><br>Then, f=
or each object t of type T appearing where a type-id is expected ( or for a=
ny explicit typename(t)/typename(T) ) the following replacement occurs<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: #660;" class=3D"styled-by-prettify">...</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify">A</span><span st=
yle=3D"color: #080;" class=3D"styled-by-prettify"><t></span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">...</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"><br><br></span><span style=3D"col=
or: #800;" class=3D"styled-by-prettify">// ---></span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"><br><br>decl</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">-</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify">spec type</span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">-</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify">id</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">[</span><span style=3D"color: #066;" class=3D"styled-by-pre=
ttify">2</span><span style=3D"color: #660;" class=3D"styled-by-prettify">]<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> r</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> t</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">.</span><span style=3D"color: #008;"=
class=3D"styled-by-prettify">operator</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"s=
tyled-by-prettify">typename</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">()</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: #000;" class=3D"styled-by-prettify"> </span>=
<span style=3D"color: #800;" class=3D"styled-by-prettify">// in the first e=
nclosing viable scope</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"><br><br></span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">...</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
">A</span><span style=3D"color: #660;" class=3D"styled-by-prettify"><</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"> T</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">::</span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">operator</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #008;" class=3D"styled-by-prettify">typename</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify"><</span><span style=3D"color: #000;"=
class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D=
"styled-by-prettify">get</span><span style=3D"color: #660;" class=3D"styled=
-by-prettify"><</span><span style=3D"color: #066;" class=3D"styled-by-pr=
ettify">0</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&=
gt;(</span><span style=3D"color: #000;" class=3D"styled-by-prettify">r</spa=
n><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: #008;" class=3D"styled-by-prettify">get</span><span style=3D"color: =
#660;" 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"styl=
ed-by-prettify">r</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">),</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-by-prettify"> </span><span st=
yle=3D"color: #008;" class=3D"styled-by-prettify">get</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify"><</span><span style=3D"color:=
#000;" class=3D"styled-by-prettify"> tuple_size</span><span style=3D"color=
: #660;" class=3D"styled-by-prettify"><</span><span style=3D"color: #008=
;" class=3D"styled-by-prettify">decltype</span><span style=3D"color: #660;"=
class=3D"styled-by-prettify">(</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify">r</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">)>::</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify">value </span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">>(</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
r</span><span style=3D"color: #660;" class=3D"styled-by-prettify">)</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: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">>...</span><span style=3D"color: #000;"=
class=3D"styled-by-prettify"><br></span></div></code></div><br>finally, as=
a concrete example ( recall the OP for the complete use cases ):<br><br><d=
iv class=3D"prettyprint" style=3D"background-color: rgb(250, 250, 250); bor=
der-color: rgb(187, 187, 187); border-style: solid; border-width: 1px; word=
-wrap: break-word;"><code class=3D"prettyprint"><div class=3D"subprettyprin=
t"><span style=3D"color: #800;" class=3D"styled-by-prettify">#include</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span st=
yle=3D"color: #080;" class=3D"styled-by-prettify"><tuple></span><span=
style=3D"color: #000;" class=3D"styled-by-prettify"><br><br></span><span s=
tyle=3D"color: #008;" class=3D"styled-by-prettify">template</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify"><</span><span style=3D"=
color: #008;" class=3D"styled-by-prettify">class</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> T</span><span style=3D"color: #660;"=
class=3D"styled-by-prettify">></span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"style=
d-by-prettify">struct</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"> A</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></=
span><span style=3D"color: #008;" class=3D"styled-by-prettify">template</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify"><</span><sp=
an style=3D"color: #008;" class=3D"styled-by-prettify">int</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"> N</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">></span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" clas=
s=3D"styled-by-prettify">struct</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"> C</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">;</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"><br><br></span><span style=3D"color: #008;" class=3D"styled-by-prettify=
">struct</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> B=
<br></span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"><br> &nbs=
p; </span><span style=3D"color: #008;" class=3D"styled-by-prettify">templat=
e</span><span style=3D"color: #660;" class=3D"styled-by-prettify"><</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span s=
tyle=3D"color: #008;" class=3D"styled-by-prettify">int</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"> N </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"colo=
r: #008;" class=3D"styled-by-prettify">operator</span><span style=3D"color:=
#000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" c=
lass=3D"styled-by-prettify">typename</span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">(</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> C</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify"><</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y">N</span><span style=3D"color: #660;" class=3D"styled-by-prettify">></=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><spa=
n 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=
: #660;" class=3D"styled-by-prettify">{</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"=
styled-by-prettify">return</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> std</span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">::</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
">make_tuple</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: #008;" class=3D"styled-by-prettify">this</span><span=
style=3D"color: #660;" class=3D"styled-by-prettify">-></span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify">n </span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">);</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">}</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"><br><br> </span><span style=3D"color: #008;" cl=
ass=3D"styled-by-prettify">int</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"> n</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: #660;" class=3D"styled-by-prettify">};<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br></s=
pan><span style=3D"color: #008;" class=3D"styled-by-prettify">int</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"> main</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">()</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">{</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"><br> </span><span style=3D"color: #=
008;" class=3D"styled-by-prettify">constexpr</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> B b</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">{</span><span style=3D"color: #066;" class=3D"s=
tyled-by-prettify">4</span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">};</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"><br><br> A</span><span style=3D"color: #080;" class=3D"style=
d-by-prettify"><b></span><span style=3D"color: #000;" class=3D"styled=
-by-prettify"> a</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></span><sp=
an style=3D"color: #800;" class=3D"styled-by-prettify">// as if</span><span=
style=3D"color: #000;" class=3D"styled-by-prettify"><br><br></span><span s=
tyle=3D"color: #008;" class=3D"styled-by-prettify">int</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"> main</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">()</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"><br></span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">{</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"><br> </span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">constexpr</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> B b</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">{</span><span style=3D"color: #066;" class=3D"styled-by-p=
rettify">4</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
};</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br>=
</span><span style=3D"color: #008;" class=3D"styled-by-pretti=
fy">constexpr</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> std</span><span style=3D"color: #660;" class=3D"styled-by-prettify">::<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify">tuple</span=
><span style=3D"color: #080;" class=3D"styled-by-prettify"><int></spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> r</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> b</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">.</span><span style=3D"color: #008;" cla=
ss=3D"styled-by-prettify">operator</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"style=
d-by-prettify">typename</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">()</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">};</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br> &=
nbsp; A</span><span style=3D"color: #660;" class=3D"styled-by-prettify"><=
;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> B</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">::</span><span st=
yle=3D"color: #008;" class=3D"styled-by-prettify">operator</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"colo=
r: #008;" class=3D"styled-by-prettify">typename</span><span style=3D"color:=
#660;" class=3D"styled-by-prettify"><</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">get</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify"><</span><span style=3D"color: #066;" class=3D"styled-by=
-prettify">0</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">>(</span><span style=3D"color: #000;" class=3D"styled-by-prettify">r</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">)</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=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: #660=
;" class=3D"styled-by-prettify">></span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> a</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">;</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> </span><span style=3D"color: #800;" class=3D"styled-by-prettify">=
// that is, A<C<4>></span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"><br></span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">}</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"><br></span></div></code></div><br>note that this is a much more gener=
al solution, as it allows "nesting" these generalized-non-type template par=
ameters in operator typename delcations ...</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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<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_1415_15453439.1379922853443--
.
Author: MJanes <max.jns@gmail.com>
Date: Mon, 23 Sep 2013 01:32:26 -0700 (PDT)
Raw View
------=_Part_1495_4658827.1379925146811
Content-Type: text/plain; charset=ISO-8859-1
corrigendum:
if no return type has been specified, std:::tuple would be assumed, with
> elements being the types appearing in the t-param-list.
>
introduces unnecessarely restrictive constraints; instead, it should be
if no return type has been specified, it's deduced as for usual auto return
type deduction rules.
--
---
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_1495_4658827.1379925146811
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">corrigendum:<br><br><blockquote class=3D"gmail_quote" styl=
e=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left:=
1ex;"><div dir=3D"ltr">if no return type has been specified, std:::tuple w=
ould be assumed, with elements being the types appearing in the t-param-lis=
t.<br></div></blockquote><div><br>introduces unnecessarely restrictive cons=
traints; instead, it should be <br><br>if no return type has been specified=
, it's deduced as for usual auto return type deduction rules.<br></div></di=
v>
<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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<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_1495_4658827.1379925146811--
.
Author: MJanes <max.jns@gmail.com>
Date: Mon, 23 Sep 2013 02:06:16 -0700 (PDT)
Raw View
------=_Part_100_24203108.1379927176804
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
oh sorry, another error ( we can't edit post, can we ? ): in
Il giorno luned=EC 23 settembre 2013 09:54:13 UTC+2, MJanes ha scritto:
> // any attr-spec, decl-spec, cv, ref, etc.. in the original declaration=
=20
> belongs to this function
> template< t-param-list >
> type-id[2] typename_func__() { function-body }
>
clearly, there should be no "template< t-param-list >" there.=20
typename_func is a non-template function ( yes, any dependent expression=20
appearing in type-id[2] or in the function body would give a compiler error=
=20
).
--=20
---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
------=_Part_100_24203108.1379927176804
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">oh sorry, another error ( we can't edit post, can we ? ):&=
nbsp; in<br><br>Il giorno luned=EC 23 settembre 2013 09:54:13 UTC+2, MJanes=
ha scritto:<br><blockquote class=3D"gmail_quote" style=3D"margin: 0;margin=
-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"lt=
r"><div 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><div>=
<span style=3D"color:#800">// any attr-spec, decl-spec, cv, ref, etc.. in t=
he original declaration belongs to this function</span><span style=3D"color=
:#000"><br></span><span style=3D"color:#008">template</span><span style=3D"=
color:#660"><</span><span style=3D"color:#000"> t</span><span style=3D"c=
olor:#660">-</span><span style=3D"color:#000">param</span><span style=3D"co=
lor:#660">-</span><span style=3D"color:#000">list </span><span style=3D"col=
or:#660">></span><span style=3D"color:#000"><br>type</span><span style=
=3D"color:#660">-</span><span style=3D"color:#000">id</span><span style=3D"=
color:#660">[</span><span style=3D"color:#066">2</span><span style=3D"color=
:#660">]</span><span style=3D"color:#000"> typename_func__</span><span styl=
e=3D"color:#660">()</span><span style=3D"color:#000"> </span><span style=3D=
"color:#660">{</span><span style=3D"color:#000"> </span><span style=3D"colo=
r:#008">function</span><span style=3D"color:#660">-</span><span style=3D"co=
lor:#000">body </span><span style=3D"color:#660">}</span><span style=3D"col=
or:#000"></span><span style=3D"color:#000"><br></span></div></code></div></=
div></blockquote><div><br>clearly, there should be no "<code><span style=3D=
"color:#008">template</span><span style=3D"color:#660"><</span><span sty=
le=3D"color:#000"> t</span><span style=3D"color:#660">-</span><span style=
=3D"color:#000">param</span><span style=3D"color:#660">-</span><span style=
=3D"color:#000">list </span><span style=3D"color:#660">></span><span sty=
le=3D"color:#000"></span></code>" there. typename_func is a non-templ=
ate function<code></code> ( yes, any dependent expression appearing in type=
-id[2] or in the function body would give a compiler error ).</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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<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_100_24203108.1379927176804--
.
Author: MJanes <max.jns@gmail.com>
Date: Mon, 23 Sep 2013 07:53:13 -0700 (PDT)
Raw View
------=_Part_515_28661039.1379947993888
Content-Type: text/plain; charset=ISO-8859-1
one last thing ... :)
firstly, thinking about it, the syntax above can be improved because using
the function argument to express the "converted" typeid may be
inappropriate and confusing after all. The idea remains the same, that is
to compactly declare a template alias and a non-template function to be
used by the implicit "type-conversion" mechanism to obtain generalized non
type template parameters.
Maybe, a clearer syntax could be
template< t-param-list >
attr-spec decl-spec operator typename = typeid ()
optional_trailing_ret_type { function-body }
now, here is a working(*)(**) macro based prototype to play with:
(*) the prototype "works" with 1-size tuples only, and supports just one
level of recursion; the true code in hypothetical case of acceptance would
look the same with all the appropriate macros A,F,... dropped. The meaning
should be obvious, please tell me if not ...
(**) tested in gcc4.7.2, c++11 mode
#include <tuple>
// partial macro prototype:
#include <type_traits>
#define D( E, EQ, TYPEID ) \
using typename_alias_ = TYPEID; \
constexpr auto typename_func_
#define A_operator
#define typename_A typename_alias_
#define A( E ) A_##E##_A
#define F_operator
#define typename_F typename_func_
#define F( E ) F_##E##_F
#define X( M ) X_
#define X_( M ) \
std::remove_reference<decltype(M)>::type::A(operator typename) \
< std::get<0>( (M).F(operator typename)() ) > \
#define E( M ) \
std::remove_reference<decltype(M)>::type::A(operator typename) \
< std::get<0>( (M).F(operator typename)() ) > \
#define RE( M ) \
std::remove_reference<decltype(M)>::type::A(operator typename) \
< E( std::get<0>( (M).F(operator typename)() ) ) > \
// example:
template< class T > struct A {};
template< int N > struct C {};
template< class T > struct C2 {};
struct B
{
int n;
template< int N >
D( operator typename, =, C<N> ) () -> std::tuple<int> { return
std::make_tuple( n ); }
};
struct B2
{
B b;
template< class T >
D( operator typename, =, C2<T> ) () -> std::tuple<B> { return
std::make_tuple( b ); }
};
int main()
{
constexpr B b{1};
constexpr B2 b2{b};
B::A(operator typename)<0> c; // a C<0>
b.F(operator typename)(); // returns a tuple<int>
X(typename)(b) c2; // a C<1>
A<E(b)> a; // an A<C<1>>
A<RE(b2)> a2; // an A<C2<C<1>>>
}
--
---
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_515_28661039.1379947993888
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">one last thing ... :)<br><br>firstly, thinking about it, t=
he syntax above can be improved because using the function argument to expr=
ess the "converted" typeid may be inappropriate and confusing after all. Th=
e idea remains the same, that is to compactly declare a template alias and =
a non-template function to be used by the implicit "type-conversion" mechan=
ism to obtain generalized non type template parameters.<br>Maybe, a clearer=
syntax could be<br><br>template< t-param-list ><br>attr-spec decl-sp=
ec operator typename =3D typeid () optional_trailing_ret_type { function-bo=
dy }<br><br>now, here is a working(*)(**) macro based prototype to play wit=
h:<br><br>(*) the prototype "works" with 1-size tuples only, and supports j=
ust one level of recursion; the true code in hypothetical case of acceptanc=
e would look the same with all the appropriate macros A,F,... dropped. The =
meaning should be obvious, please tell me if not ...<br>(**) tested in gcc4=
..7.2, c++11 mode<br><br>#include <tuple><br><br>// partial macro prot=
otype:<br><br>#include <type_traits><br><br>#define D( E, EQ, TYPEID =
) \<br>&n=
bsp; using typename_alias_ =3D TYPEID; \<br>&=
nbsp; constexpr auto typename_func_<br><br>#define A_operator<b=
r>#define typename_A typename_alias_<br>#define A( E ) A_##E##_A<br><br>#de=
fine F_operator<br>#define typename_F typename_func_<br>#define F( E ) F_##=
E##_F<br><br>#define X( M ) X_<br>#define X_( M ) &=
nbsp; =
 =
; &nbs=
p; \<br> std::remove_reference<decltype(M)=
>::type::A(operator typename) \<br> =
< std::get<0>( (M).F(operator typename)() ) >=
; &nbs=
p;\<br><br><br>#define E( M ) &n=
bsp; &=
nbsp; =
\<br>=
std::remove_reference<decltype(M)>::type::A(operat=
or typename) \<br> &=
lt; std::get<0>( (M).F(operator typename)() ) > =
\<br><br>#define R=
E( M ) =
 =
; &nbs=
p; \<br> std:=
:remove_reference<decltype(M)>::type::A(operator typename)  =
; \<br> < E( std::get<0>=
;( (M).F(operator typename)() ) ) >  =
; \<br><br>// example:<br><br>template< class T > s=
truct A {};<br>template< int N > struct C {};<br>template< class T=
> struct C2 {};<br><br>struct B<br>{<br> int n;<br><b=
r> template< int N ><br> D( opera=
tor typename, =3D, C<N> ) () -> std::tuple<int> { return std=
::make_tuple( n ); }<br>};<br><br>struct B2<br>{<br> B b;=
<br><br> template< class T ><br> =
D( operator typename, =3D, C2<T> ) () -> std::tuple<B> { ret=
urn std::make_tuple( b ); }<br>};<br><br>int main()<br>{<br> &n=
bsp;constexpr B b{1};<br> constexpr B2 b2{b};<br><br>&nbs=
p; B::A(operator typename)<0> c; // a C<0><br> =
; b.F(operator typename)(); // returns a tuple<int><br><b=
r> X(typename)(b) c2; // a C<1><br><br> =
A<E(b)> a; // an A<C<1>><br> A&l=
t;RE(b2)> a2; // an A<C2<C<1>>><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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<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_515_28661039.1379947993888--
.
Author: MJanes <max.jns@gmail.com>
Date: Mon, 23 Sep 2013 07:54:14 -0700 (PDT)
Raw View
------=_Part_266_1863455.1379948054640
Content-Type: text/plain; charset=ISO-8859-1
one last thing ... :)
firstly, thinking about it, the syntax above can be improved because using
the function argument to express the "converted" typeid may be
inappropriate and confusing after all. The idea remains the same, that is
to compactly declare a template alias and a non-template function to be
used by the implicit "type-conversion" mechanism to obtain generalized non
type template parameters.
Maybe, a clearer syntax could be
template< t-param-list >
attr-spec decl-spec operator typename = typeid ()
optional_trailing_ret_type { function-body }
now, here is a working(*)(**) macro based prototype to play with:
(*) the prototype "works" with 1-size tuples only, and supports just one
level of recursion; the true code in hypothetical case of acceptance would
look the same with all the appropriate macros A,F,... dropped. The meaning
should be obvious, please tell me if not ...
(**) tested in gcc4.7.2, c++11 mode
#include <tuple>
// partial macro prototype:
#include <type_traits>
#define D( E, EQ, TYPEID ) \
using typename_alias_ = TYPEID; \
constexpr auto typename_func_
#define A_operator
#define typename_A typename_alias_
#define A( E ) A_##E##_A
#define F_operator
#define typename_F typename_func_
#define F( E ) F_##E##_F
#define X( M ) X_
#define X_( M ) \
std::remove_reference<decltype(M)>::type::A(operator typename) \
< std::get<0>( (M).F(operator typename)() ) > \
#define E( M ) \
std::remove_reference<decltype(M)>::type::A(operator typename) \
< std::get<0>( (M).F(operator typename)() ) > \
#define RE( M ) \
std::remove_reference<decltype(M)>::type::A(operator typename) \
< E( std::get<0>( (M).F(operator typename)() ) ) > \
// example:
template< class T > struct A {};
template< int N > struct C {};
template< class T > struct C2 {};
struct B
{
int n;
template< int N >
D( operator typename, =, C<N> ) () -> std::tuple<int> { return std::
make_tuple( n ); }
};
struct B2
{
B b;
template< class T >
D( operator typename, =, C2<T> ) () -> std::tuple<B> { return std::
make_tuple( b ); }
};
int main()
{
constexpr B b{1};
constexpr B2 b2{b};
B::A(operator typename)<0> c; // a C<0>
b.F(operator typename)(); // returns a tuple<int>
X(typename)(b) c2; // a C<1>
A<E(b)> a; // an A<C<1>>
A<RE(b2)> a2; // an A<C2<C<1>>>
}
--
---
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_266_1863455.1379948054640
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">one last thing ... :)<br><br>firstly, thinking about it, t=
he syntax above can be improved because using the function argument to expr=
ess the "converted" typeid may be inappropriate and confusing after all. Th=
e idea remains the same, that is to compactly declare a template alias and =
a non-template function to be used by the implicit "type-conversion" mechan=
ism to obtain generalized non type template parameters.<br>Maybe, a clearer=
syntax could be<br><br>template< t-param-list ><br>attr-spec decl-sp=
ec operator typename =3D typeid () optional_trailing_ret_type { function-bo=
dy }<br><br>now, here is a working(*)(**) macro based prototype to play wit=
h:<br><br>(*) the prototype "works" with 1-size tuples only, and supports j=
ust one level of recursion; the true code in hypothetical case of acceptanc=
e would look the same with all the appropriate macros A,F,... dropped. The =
meaning should be obvious, please tell me if not ...<br>(**) tested in gcc4=
..7.2, c++11 mode<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: #000;" class=3D"styled-b=
y-prettify"><br></span><span style=3D"color: #800;" class=3D"styled-by-pret=
tify">#include</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> </span><span style=3D"color: #080;" class=3D"styled-by-prettify"><t=
uple></span><span style=3D"color: #000;" class=3D"styled-by-prettify"><b=
r><br></span><span style=3D"color: #800;" class=3D"styled-by-prettify">// p=
artial macro prototype:</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"><br><br></span><span style=3D"color: #800;" class=3D"styled-by=
-prettify">#include</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> </span><span style=3D"color: #080;" class=3D"styled-by-prettify">=
<type_traits></span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"><br><br></span><span style=3D"color: #800;" class=3D"styled-by-pre=
ttify">#define</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> D</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"> E</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> EQ</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"> TYPEID </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: #660;" class=3D"styled-by-prettify">\</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"><br> </span><span s=
tyle=3D"color: #008;" class=3D"styled-by-prettify">using</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> typename_alias_ </span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> TYPEID</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"colo=
r: #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">constexpr</span><span style=3D"color:=
#000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" c=
lass=3D"styled-by-prettify">auto</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> typename_func_<br><br></span><span style=3D"color:=
#800;" class=3D"styled-by-prettify">#define</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> A_operator<br></span><span style=3D"colo=
r: #800;" class=3D"styled-by-prettify">#define</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify"> typename_A typename_alias_<br></span><=
span style=3D"color: #800;" class=3D"styled-by-prettify">#define</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> A</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> E </span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">)</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> A_</span><span style=3D"color: #800;" class=3D"sty=
led-by-prettify">##E##_A</span><span style=3D"color: #000;" class=3D"styled=
-by-prettify"><br><br></span><span style=3D"color: #800;" class=3D"styled-b=
y-prettify">#define</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> F_operator<br></span><span style=3D"color: #800;" class=3D"styled=
-by-prettify">#define</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"> typename_F typename_func_<br></span><span style=3D"color: #800;=
" class=3D"styled-by-prettify">#define</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"> F</span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">(</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"> E </span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">)</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> F_</=
span><span style=3D"color: #800;" class=3D"styled-by-prettify">##E##_F</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br></span>=
<span style=3D"color: #800;" class=3D"styled-by-prettify">#define</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"> X</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> M </span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">)</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> X_<br></span><span style=3D"color: #800;" class=3D=
"styled-by-prettify">#define</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> X_</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">(</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> M </span><span style=3D"color: #660;" class=3D"styled-by-prettify">)</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
&nbs=
p; &n=
bsp; </span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">\</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"><br> std</span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">::</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify">remove_reference</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify"><</span><span style=3D"color: #008;" class=3D"st=
yled-by-prettify">decltype</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">(</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify">M</span><span style=3D"color: #660;" class=3D"styled-by-prettify">)&=
gt;::</span><span style=3D"color: #000;" class=3D"styled-by-prettify">type<=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">::</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify">A</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color=
: #008;" class=3D"styled-by-prettify">operator</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" cl=
ass=3D"styled-by-prettify">typename</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">)</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> </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: #66=
0;" class=3D"styled-by-prettify"><</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> std</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">::</span><span style=3D"color: #008;" class=3D"styled-=
by-prettify">get</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify"><</span><span style=3D"color: #066;" class=3D"styled-by-prettify">=
0</span><span style=3D"color: #660;" class=3D"styled-by-prettify">>(</sp=
an><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-by-prettify">M</span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">).</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify">F</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">(</span><span style=3D"color: #008;" class=3D"styled-by-pr=
ettify">operator</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">typ=
ename</span><span style=3D"color: #660;" class=3D"styled-by-prettify">)()</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><spa=
n 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=
: #660;" class=3D"styled-by-prettify">></span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> =
</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">\</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><b=
r><br></span><span style=3D"color: #800;" class=3D"styled-by-prettify">#def=
ine</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> E</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"> M </span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">)</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"> &nbs=
p; &n=
bsp; =
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">\</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"><br> &n=
bsp; std</span><span style=3D"color: #660;" class=3D"styled-by-prettify">::=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify">remove_ref=
erence</span><span style=3D"color: #660;" class=3D"styled-by-prettify"><=
</span><span style=3D"color: #008;" class=3D"styled-by-prettify">decltype</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify">M</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">)>::</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify">type</span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">::</span><span style=3D"color: #000;"=
class=3D"styled-by-prettify">A</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">(</span><span style=3D"color: #008;" class=3D"styled-b=
y-prettify">operator</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify"=
>typename</span><span style=3D"color: #660;" class=3D"styled-by-prettify">)=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> &n=
bsp;</span><span style=3D"color: #660;" class=3D"styled-by-prettify">\</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"><br> &nbs=
p; </span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify"><</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
> std</span><span style=3D"color: #660;" class=3D"styled-by-prettify">::</s=
pan><span style=3D"color: #008;" class=3D"styled-by-prettify">get</span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify"><</span><span sty=
le=3D"color: #066;" class=3D"styled-by-prettify">0</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">>(</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">M</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">).</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
F</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><=
span style=3D"color: #008;" class=3D"styled-by-prettify">operator</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">typename</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">)()</span><span style=3D"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: #660;" class=3D"style=
d-by-prettify">></span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> </span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">\</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br><br></span><span style=
=3D"color: #800;" class=3D"styled-by-prettify">#define</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"> RE</span><span style=3D"color:=
#660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"> M </span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">)</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> =
&nbs=
p; </span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">\</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"><br> std</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">::</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify">remove_reference</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify"><</span><span style=3D"c=
olor: #008;" class=3D"styled-by-prettify">decltype</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify">M</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">)>::</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify">type</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">::</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify">A</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(<=
/span><span style=3D"color: #008;" class=3D"styled-by-prettify">operator</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span=
style=3D"color: #008;" class=3D"styled-by-prettify">typename</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">)</span><span style=3D"c=
olor: #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"><br> </spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify"><</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> E</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> std</span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">::</span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">get</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify"><</span><span style=3D"color: #066;" class=3D"styled-by=
-prettify">0</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: #660;" class=3D"styled-by-prettify">(</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify">M</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">).</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify">F</span><span style=3D"color: #660;"=
class=3D"styled-by-prettify">(</span><span style=3D"color: #008;" class=3D=
"styled-by-prettify">operator</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-=
prettify">typename</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">)()</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-by-prettify"> </span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">)</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;" clas=
s=3D"styled-by-prettify"> </span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">\</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"><br><br></span><span style=
=3D"color: #800;" class=3D"styled-by-prettify">// example:</span><span styl=
e=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: #660;" class=3D"styled-by-prettify"><</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008=
;" class=3D"styled-by-prettify">class</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> T </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: #008;" class=3D"styled-by-prett=
ify">struct</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
> A </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: #008;" class=3D"styled-by-prettify">template</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify"><</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"colo=
r: #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;" clas=
s=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">struct</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> C </span><span style=3D"color: #660;" class=3D"styled-by-prettify">{=
};</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></sp=
an><span style=3D"color: #008;" class=3D"styled-by-prettify">template</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: #008;" class=3D"styled-by-prettify">class</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"> T </span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">></span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"sty=
led-by-prettify">struct</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"> C2 </span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">{};</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
<br><br></span><span style=3D"color: #008;" class=3D"styled-by-prettify">st=
ruct</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> B<br>=
</span><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 style=3D"color: #008;" class=3D"styled-by-prettify">int</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> n</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"><br><br> </span><span =
style=3D"color: #008;" class=3D"styled-by-prettify">template</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify"><</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"> N </span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">></span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"><br> D</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">(</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-pret=
tify">operator</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">typen=
ame</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">=3D,</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"> C</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify"><</span><span style=3D"color: #000;"=
class=3D"styled-by-prettify">N</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">></span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">)</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">()</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">-></span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> std</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">::</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify">tuple</span><span style=3D"color: #080;" class=
=3D"styled-by-prettify"><int></span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"> </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">re=
turn</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> std</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">::</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify">make_tuple</span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> n </span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">);</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">}</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"><br></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: #008;" class=3D"styled-by-prettify">s=
truct</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> B2<b=
r></span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"><br> =
B b</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br> =
</span><span style=3D"color: #008;" class=3D"styled-by-prettify">tem=
plate</span><span style=3D"color: #660;" class=3D"styled-by-prettify"><<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><sp=
an style=3D"color: #008;" class=3D"styled-by-prettify">class</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> T </span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">></span><span style=3D"color:=
#000;" class=3D"styled-by-prettify"><br> D</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: #008;" =
class=3D"styled-by-prettify">operator</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"st=
yled-by-prettify">typename</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: #660;" class=3D"styled-by-prettify">=
=3D,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> C2</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify"><</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify">T</span><span style=
=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: #660=
;" class=3D"styled-by-prettify">)</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">()</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">-&=
gt;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> std</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">::</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify">tuple</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify"><</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify">B</span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">></span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">{</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify"=
>return</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> st=
d</span><span style=3D"color: #660;" class=3D"styled-by-prettify">::</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify">make_tuple</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"> b </span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">);</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">}</span><span style=3D"color: #000;" class=3D"styl=
ed-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></span><span style=3D"color: #008;" class=3D"styled-by-prettify">=
int</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> main</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">()</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"><br> </span><span styl=
e=3D"color: #008;" class=3D"styled-by-prettify">constexpr</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> B b</span><span style=3D"co=
lor: #660;" 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"styl=
ed-by-prettify"><br> </span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">constexpr</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> B2 b2</span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">{</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify">b</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">};</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><b=
r> B</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">::</span><span style=3D"color: #000;" class=3D"styled-by-prettify">A=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><s=
pan style=3D"color: #008;" class=3D"styled-by-prettify">operator</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">typename</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">)<</span><span style=3D"c=
olor: #066;" class=3D"styled-by-prettify">0</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">></span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> c</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">;</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"> </span><span style=3D"color: #800;" class=3D"styled-by-prettify"=
>// a C<0></span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"><br> b</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">.</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify">F</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</=
span><span style=3D"color: #008;" class=3D"styled-by-prettify">operator</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span =
style=3D"color: #008;" class=3D"styled-by-prettify">typename</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">)();</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #=
800;" class=3D"styled-by-prettify">// returns a tuple<int></span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"><br><br> =
X</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span>=
<span style=3D"color: #008;" class=3D"styled-by-prettify">typename</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">)(</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify">b</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">)</span><span style=3D"color: #000;"=
class=3D"styled-by-prettify"> c2</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> </span><span style=3D"color: #800;" class=3D"styled-by-pret=
tify">// a C<1></span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"><br><br> A</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify"><</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify">E</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">(</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
b</span><span style=3D"color: #660;" class=3D"styled-by-prettify">)></sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"> a</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: #=
800;" class=3D"styled-by-prettify">// an A<C<1>></span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"><br> A</span=
><span style=3D"color: #660;" class=3D"styled-by-prettify"><</span><span=
style=3D"color: #000;" class=3D"styled-by-prettify">RE</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify">b2</span><span style=3D"color: #660;"=
class=3D"styled-by-prettify">)></span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"> a2</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">;</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> </span><span style=3D"color: #800;" class=3D"styled-by-prettify">=
// an A<C2<C<1>>></span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"><br></span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">}</span></div></code></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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<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_266_1863455.1379948054640--
.
Author: inkwizytoryankes@gmail.com
Date: Mon, 23 Sep 2013 09:48:58 -0700 (PDT)
Raw View
------=_Part_94_22331594.1379954938259
Content-Type: text/plain; charset=ISO-8859-1
I think this proposition should be simplified to allowing POD classes as
template parameters (probably with restriction of floating points fields).
You will probably get most functionality that you want without adding new
syntax and rules to language.
On Monday, September 23, 2013 4:54:14 PM UTC+2, MJanes wrote:
>
> one last thing ... :)
>
> firstly, thinking about it, the syntax above can be improved because using
> the function argument to express the "converted" typeid may be
> inappropriate and confusing after all. The idea remains the same, that is
> to compactly declare a template alias and a non-template function to be
> used by the implicit "type-conversion" mechanism to obtain generalized non
> type template parameters.
> Maybe, a clearer syntax could be
>
> template< t-param-list >
> attr-spec decl-spec operator typename = typeid ()
> optional_trailing_ret_type { function-body }
>
> now, here is a working(*)(**) macro based prototype to play with:
>
> (*) the prototype "works" with 1-size tuples only, and supports just one
> level of recursion; the true code in hypothetical case of acceptance would
> look the same with all the appropriate macros A,F,... dropped. The meaning
> should be obvious, please tell me if not ...
> (**) tested in gcc4.7.2, c++11 mode
>
>
> #include <tuple>
>
> // partial macro prototype:
>
> #include <type_traits>
>
> #define D( E, EQ, TYPEID ) \
> using typename_alias_ = TYPEID; \
> constexpr auto typename_func_
>
> #define A_operator
> #define typename_A typename_alias_
> #define A( E ) A_##E##_A
>
> #define F_operator
> #define typename_F typename_func_
> #define F( E ) F_##E##_F
>
> #define X( M ) X_
> #define X_( M ) \
> std::remove_reference<decltype(M)>::type::A(operator typename) \
> < std::get<0>( (M).F(operator typename)() ) > \
>
>
> #define E( M ) \
> std::remove_reference<decltype(M)>::type::A(operator typename) \
> < std::get<0>( (M).F(operator typename)() ) > \
>
> #define RE( M ) \
> std::remove_reference<decltype(M)>::type::A(operator typename) \
> < E( std::get<0>( (M).F(operator typename)() ) ) > \
>
> // example:
>
> template< class T > struct A {};
> template< int N > struct C {};
> template< class T > struct C2 {};
>
> struct B
> {
> int n;
>
> template< int N >
> D( operator typename, =, C<N> ) () -> std::tuple<int> { return std::
> make_tuple( n ); }
> };
>
> struct B2
> {
> B b;
>
> template< class T >
> D( operator typename, =, C2<T> ) () -> std::tuple<B> { return std::
> make_tuple( b ); }
> };
>
> int main()
> {
> constexpr B b{1};
> constexpr B2 b2{b};
>
> B::A(operator typename)<0> c; // a C<0>
> b.F(operator typename)(); // returns a tuple<int>
>
> X(typename)(b) c2; // a C<1>
>
> A<E(b)> a; // an A<C<1>>
> A<RE(b2)> a2; // an A<C2<C<1>>>
> }
>
>
--
---
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_94_22331594.1379954938259
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">I think this proposition should be simplified to allowing =
POD classes as template parameters (probably with restriction of floating =
points fields).<br>You will probably get most functionality that you want w=
ithout adding new syntax and rules to language.<br><br>On Monday, September=
23, 2013 4:54:14 PM UTC+2, MJanes wrote:<blockquote class=3D"gmail_quote" =
style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-l=
eft: 1ex;"><div dir=3D"ltr">one last thing ... :)<br><br>firstly, thinking =
about it, the syntax above can be improved because using the function argum=
ent to express the "converted" typeid may be inappropriate and confusing af=
ter all. The idea remains the same, that is to compactly declare a template=
alias and a non-template function to be used by the implicit "type-convers=
ion" mechanism to obtain generalized non type template parameters.<br>Maybe=
, a clearer syntax could be<br><br>template< t-param-list ><br>attr-s=
pec decl-spec operator typename =3D typeid () optional_trailing_ret_type { =
function-body }<br><br>now, here is a working(*)(**) macro based prototype =
to play with:<br><br>(*) the prototype "works" with 1-size tuples only, and=
supports just one level of recursion; the true code in hypothetical case o=
f acceptance would look the same with all the appropriate macros A,F,... dr=
opped. The meaning should be obvious, please tell me if not ...<br>(**) tes=
ted in gcc4.7.2, c++11 mode<br><br><div style=3D"background-color:rgb(250,2=
50,250);border-color:rgb(187,187,187);border-style:solid;border-width:1px;w=
ord-wrap:break-word"><code><div><span style=3D"color:#000"><br></span><span=
style=3D"color:#800">#include</span><span style=3D"color:#000"> </span><sp=
an style=3D"color:#080"><tuple></span><span style=3D"color:#000"><br>=
<br></span><span style=3D"color:#800">// partial macro prototype:</span><sp=
an style=3D"color:#000"><br><br></span><span style=3D"color:#800">#include<=
/span><span style=3D"color:#000"> </span><span style=3D"color:#080"><typ=
e_traits></span><span style=3D"color:#000"><br><br></span><span style=3D=
"color:#800">#define</span><span style=3D"color:#000"> D</span><span style=
=3D"color:#660">(</span><span style=3D"color:#000"> E</span><span style=3D"=
color:#660">,</span><span style=3D"color:#000"> EQ</span><span style=3D"col=
or:#660">,</span><span style=3D"color:#000"> TYPEID </span><span style=3D"c=
olor:#660">)</span><span style=3D"color:#000"> =
</span><span style=3D"color:#660">\</span><span style=3D"color=
:#000"><br> </span><span style=3D"color:#008">using</span><spa=
n style=3D"color:#000"> typename_alias_ </span><span style=3D"color:#660">=
=3D</span><span style=3D"color:#000"> TYPEID</span><span style=3D"color:#66=
0">;</span><span style=3D"color:#000"> </span><span style=3D"c=
olor:#660">\</span><span style=3D"color:#000"><br> </span><spa=
n style=3D"color:#008">constexpr</span><span style=3D"color:#000"> </span><=
span style=3D"color:#008">auto</span><span style=3D"color:#000"> typename_f=
unc_<br><br></span><span style=3D"color:#800">#define</span><span style=3D"=
color:#000"> A_operator<br></span><span style=3D"color:#800">#define</span>=
<span style=3D"color:#000"> typename_A typename_alias_<br></span><span styl=
e=3D"color:#800">#define</span><span style=3D"color:#000"> A</span><span st=
yle=3D"color:#660">(</span><span style=3D"color:#000"> E </span><span style=
=3D"color:#660">)</span><span style=3D"color:#000"> A_</span><span style=3D=
"color:#800">##E##_A</span><span style=3D"color:#000"><br><br></span><span =
style=3D"color:#800">#define</span><span style=3D"color:#000"> F_operator<b=
r></span><span style=3D"color:#800">#define</span><span style=3D"color:#000=
"> typename_F typename_func_<br></span><span style=3D"color:#800">#define</=
span><span style=3D"color:#000"> F</span><span style=3D"color:#660">(</span=
><span style=3D"color:#000"> E </span><span style=3D"color:#660">)</span><s=
pan style=3D"color:#000"> F_</span><span style=3D"color:#800">##E##_F</span=
><span style=3D"color:#000"><br><br></span><span style=3D"color:#800">#defi=
ne</span><span style=3D"color:#000"> X</span><span style=3D"color:#660">(</=
span><span style=3D"color:#000"> M </span><span style=3D"color:#660">)</spa=
n><span style=3D"color:#000"> X_<br></span><span style=3D"color:#800">#defi=
ne</span><span style=3D"color:#000"> X_</span><span style=3D"color:#660">(<=
/span><span style=3D"color:#000"> M </span><span style=3D"color:#660">)</sp=
an><span style=3D"color:#000"> &n=
bsp; =
 =
;</span><span style=3D"color:#660">\</span><span style=3D"color:#000"><br>&=
nbsp; std</span><span style=3D"color:#660">::</span><span style=3D"c=
olor:#000">remove_reference</span><span style=3D"color:#660"><</span><sp=
an style=3D"color:#008">decltype</span><span style=3D"color:#660"><wbr>(</s=
pan><span style=3D"color:#000">M</span><span style=3D"color:#660">)>::</=
span><span style=3D"color:#000">type</span><span style=3D"color:#660">::</s=
pan><span style=3D"color:#000">A</span><span style=3D"color:#660">(</span><=
span style=3D"color:#008">operator</span><span style=3D"color:#000"> </span=
><span style=3D"color:#008">typename</span><span style=3D"color:#660">)</sp=
an><span style=3D"color:#000"> </span><span style=3D"color:#66=
0">\</span><span style=3D"color:#000"><br> </spa=
n><span style=3D"color:#660"><</span><span style=3D"color:#000"> std</sp=
an><span style=3D"color:#660">::</span><span style=3D"color:#008">get</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"> </span><s=
pan style=3D"color:#660">(</span><span style=3D"color:#000">M</span><span s=
tyle=3D"color:#660">).</span><span style=3D"color:#000">F</span><span style=
=3D"color:#660">(</span><span style=3D"color:#008">operator</span><span sty=
le=3D"color:#000"> </span><span style=3D"color:#008">typename</span><span s=
tyle=3D"color:#660">)()</span><span style=3D"color:#000"> </span><span styl=
e=3D"color:#660">)</span><span style=3D"color:#000"> </span><span style=3D"=
color:#660">></span><span style=3D"color:#000"> &nb=
sp; </span><span style=3D"color:#660">\</span><s=
pan style=3D"color:#000"><br><br><br></span><span style=3D"color:#800">#def=
ine</span><span style=3D"color:#000"> E</span><span style=3D"color:#660">(<=
/span><span style=3D"color:#000"> M </span><span style=3D"color:#660">)</sp=
an><span style=3D"color:#000"> &n=
bsp; =
 =
;</span><span style=3D"color:#660">\</span><span style=3D"color:#000"><br>&=
nbsp; std</span><span style=3D"color:#660">::</span><span style=3D"c=
olor:#000">remove_reference</span><span style=3D"color:#660"><</span><sp=
an style=3D"color:#008">decltype</span><span style=3D"color:#660"><wbr>(</s=
pan><span style=3D"color:#000">M</span><span style=3D"color:#660">)>::</=
span><span style=3D"color:#000">type</span><span style=3D"color:#660">::</s=
pan><span style=3D"color:#000">A</span><span style=3D"color:#660">(</span><=
span style=3D"color:#008">operator</span><span style=3D"color:#000"> </span=
><span style=3D"color:#008">typename</span><span style=3D"color:#660">)</sp=
an><span style=3D"color:#000"> </span><span style=3D"color:#66=
0">\</span><span style=3D"color:#000"><br> </spa=
n><span style=3D"color:#660"><</span><span style=3D"color:#000"> std</sp=
an><span style=3D"color:#660">::</span><span style=3D"color:#008">get</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"> </span><s=
pan style=3D"color:#660">(</span><span style=3D"color:#000">M</span><span s=
tyle=3D"color:#660">).</span><span style=3D"color:#000">F</span><span style=
=3D"color:#660">(</span><span style=3D"color:#008">operator</span><span sty=
le=3D"color:#000"> </span><span style=3D"color:#008">typename</span><span s=
tyle=3D"color:#660">)()</span><span style=3D"color:#000"> </span><span styl=
e=3D"color:#660">)</span><span style=3D"color:#000"> </span><span style=3D"=
color:#660">></span><span style=3D"color:#000"> &nb=
sp; </span><span style=3D"color:#660">\</span><s=
pan style=3D"color:#000"><br><br></span><span style=3D"color:#800">#define<=
/span><span style=3D"color:#000"> RE</span><span style=3D"color:#660">(</sp=
an><span style=3D"color:#000"> M </span><span style=3D"color:#660">)</span>=
<span style=3D"color:#000">  =
; &nb=
sp; </=
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">remove_reference</span><span style=3D"color:#660"><</span><span =
style=3D"color:#008">decltype</span><span style=3D"color:#660"><wbr>(</span=
><span style=3D"color:#000">M</span><span style=3D"color:#660">)>::</spa=
n><span style=3D"color:#000">type</span><span style=3D"color:#660">::</span=
><span style=3D"color:#000">A</span><span style=3D"color:#660">(</span><spa=
n style=3D"color:#008">operator</span><span style=3D"color:#000"> </span><s=
pan style=3D"color:#008">typename</span><span style=3D"color:#660">)</span>=
<span style=3D"color:#000"> </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"> E</span><s=
pan style=3D"color:#660">(</span><span style=3D"color:#000"> std</span><spa=
n style=3D"color:#660">::</span><span style=3D"color:#008">get</span><span =
style=3D"color:#660"><</span><span style=3D"color:#066">0</span><span st=
yle=3D"color:#660">>(</span><span style=3D"color:#000"> </span><span sty=
le=3D"color:#660">(</span><span style=3D"color:#000">M</span><span style=3D=
"color:#660">).</span><span style=3D"color:#000">F</span><span style=3D"col=
or:#660">(</span><span style=3D"color:#008">operator</span><span style=3D"c=
olor:#000"> </span><span style=3D"color:#008">typename</span><span style=3D=
"color:#660">)()</span><span style=3D"color:#000"> </span><span style=3D"co=
lor:#660">)</span><span style=3D"color:#000"> </span><span style=3D"color:#=
660">)</span><span style=3D"color:#000"> </span><span style=3D"color:#660">=
></span><span style=3D"color:#000"> &=
nbsp;</span><span style=3D"color:#660">\</span><span style=3D"color:#000"><=
br><br></span><span style=3D"color:#800">// example:</span><span style=3D"c=
olor:#000"><br><br></span><span style=3D"color:#008">template</span><span s=
tyle=3D"color:#660"><</span><span style=3D"color:#000"> </span><span sty=
le=3D"color:#008">class</span><span style=3D"color:#000"> T </span><span st=
yle=3D"color:#660">></span><span style=3D"color:#000"> </span><span styl=
e=3D"color:#008">struct</span><span style=3D"color:#000"> A </span><span st=
yle=3D"color:#660">{};</span><span style=3D"color:#000"><br></span><span st=
yle=3D"color:#008">template</span><span style=3D"color:#660"><</span><sp=
an style=3D"color:#000"> </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"> </span><span style=3D"color:#008">struct</span><span =
style=3D"color:#000"> C </span><span style=3D"color:#660">{};</span><span s=
tyle=3D"color:#000"><br></span><span style=3D"color:#008">template</span><s=
pan style=3D"color:#660"><</span><span style=3D"color:#000"> </span><spa=
n style=3D"color:#008">class</span><span style=3D"color:#000"> T </span><sp=
an style=3D"color:#660">></span><span style=3D"color:#000"> </span><span=
style=3D"color:#008">struct</span><span style=3D"color:#000"> C2 </span><s=
pan style=3D"color:#660">{};</span><span style=3D"color:#000"><br><br></spa=
n><span style=3D"color:#008">struct</span><span style=3D"color:#000"> B<br>=
</span><span style=3D"color:#660">{</span><span style=3D"color:#000"><br>&n=
bsp; </span><span style=3D"color:#008">int</span><span style=3D"colo=
r:#000"> n</span><span style=3D"color:#660">;</span><span style=3D"color:#0=
00"><br><br> </span><span style=3D"color:#008">template</span>=
<span style=3D"color:#660"><</span><span style=3D"color:#000"> </span><s=
pan style=3D"color:#008">int</span><span style=3D"color:#000"> N </span><sp=
an style=3D"color:#660">></span><span style=3D"color:#000"><br> &n=
bsp; D</span><span style=3D"color:#660">(</span><span style=3D"color:#000">=
</span><span style=3D"color:#008">operator</span><span style=3D"color:#000=
"> </span><span style=3D"color:#008">typename</span><span style=3D"color:#6=
60">,</span><span style=3D"color:#000"> </span><span style=3D"color:#660">=
=3D,</span><span style=3D"color:#000"> C</span><span style=3D"color:#660">&=
lt;</span><span style=3D"color:#000">N</span><span style=3D"color:#660">>=
;</span><span style=3D"color:#000"> </span><span style=3D"color:#660">)</sp=
an><span style=3D"color:#000"> </span><span style=3D"color:#660">()</span><=
span style=3D"color:#000"> </span><span style=3D"color:#660">-></span><s=
pan style=3D"color:#000"> std</span><span style=3D"color:#660">::</span><sp=
an style=3D"color:#000">tuple</span><span style=3D"color:#080"><int><=
/span><span style=3D"color:#000"> </span><span style=3D"color:#660">{</span=
><span style=3D"color:#000"> </span><span style=3D"color:#008">return</span=
><span style=3D"color:#000"> std</span><span style=3D"color:#660">::</span>=
<span style=3D"color:#000">make_tuple</span><span style=3D"color:#660">(</s=
pan><span style=3D"color:#000"> n </span><span style=3D"color:#660">);</spa=
n><span style=3D"color:#000"> </span><span style=3D"color:#660">}</span><sp=
an style=3D"color:#000"><br></span><span style=3D"color:#660">};</span><spa=
n style=3D"color:#000"><br><br></span><span style=3D"color:#008">struct</sp=
an><span style=3D"color:#000"> B2<br></span><span style=3D"color:#660">{</s=
pan><span style=3D"color:#000"><br> B b</span><span style=3D"c=
olor:#660">;</span><span style=3D"color:#000"><br><br> </span>=
<span style=3D"color:#008">template</span><span style=3D"color:#660"><</=
span><span style=3D"color:#000"> </span><span style=3D"color:#008">class</s=
pan><span style=3D"color:#000"> T </span><span style=3D"color:#660">></s=
pan><span style=3D"color:#000"><br> D</span><span style=3D"col=
or:#660">(</span><span style=3D"color:#000"> </span><span style=3D"color:#0=
08">operator</span><span style=3D"color:#000"> </span><span style=3D"color:=
#008">typename</span><span style=3D"color:#660">,</span><span style=3D"colo=
r:#000"> </span><span style=3D"color:#660">=3D,</span><span style=3D"color:=
#000"> C2</span><span style=3D"color:#660"><</span><span style=3D"color:=
#000">T</span><span style=3D"color:#660">></span><span style=3D"color:#0=
00"> </span><span style=3D"color:#660">)</span><span style=3D"color:#000"> =
</span><span style=3D"color:#660">()</span><span style=3D"color:#000"> </sp=
an><span style=3D"color:#660">-></span><span style=3D"color:#000"> std</=
span><span style=3D"color:#660">::</span><span style=3D"color:#000">tuple</=
span><span style=3D"color:#660"><</span><span style=3D"color:#000">B</sp=
an><span style=3D"color:#660">></span><span style=3D"color:#000"> </span=
><span style=3D"color:#660">{</span><span style=3D"color:#000"> </span><spa=
n style=3D"color:#008">return</span><span style=3D"color:#000"> std</span><=
span style=3D"color:#660">::</span><span style=3D"color:#000">make_tuple</s=
pan><span style=3D"color:#660">(</span><span style=3D"color:#000"> b </span=
><span style=3D"color:#660">);</span><span style=3D"color:#000"> </span><sp=
an style=3D"color:#660">}</span><span style=3D"color:#000"><br></span><span=
style=3D"color:#660">};</span><span style=3D"color:#000"><br><br></span><s=
pan style=3D"color:#008">int</span><span style=3D"color:#000"> main</span><=
span style=3D"color:#660">()</span><span style=3D"color:#000"><br></span><s=
pan style=3D"color:#660">{</span><span style=3D"color:#000"><br> &nbs=
p; </span><span style=3D"color:#008">constexpr</span><span style=3D"color:#=
000"> B b</span><span style=3D"color:#660">{</span><span style=3D"color:#06=
6">1</span><span style=3D"color:#660">};</span><span style=3D"color:#000"><=
br> </span><span style=3D"color:#008">constexpr</span><span st=
yle=3D"color:#000"> B2 b2</span><span style=3D"color:#660">{</span><span st=
yle=3D"color:#000">b</span><span style=3D"color:#660">};</span><span style=
=3D"color:#000"><br><br> B</span><span style=3D"color:#660">::=
</span><span style=3D"color:#000">A</span><span style=3D"color:#660">(</spa=
n><span style=3D"color:#008">operator</span><span style=3D"color:#000"> </s=
pan><span style=3D"color:#008">typename</span><span style=3D"color:#660">)&=
lt;</span><span style=3D"color:#066">0</span><span style=3D"color:#660">>=
;</span><span style=3D"color:#000"> c</span><span style=3D"color:#660">;</s=
pan><span style=3D"color:#000"> </span><span style=3D"color:#800">// a C<=
;0></span><span style=3D"color:#000"><br> b</span><span sty=
le=3D"color:#660">.</span><span style=3D"color:#000">F</span><span style=3D=
"color:#660">(</span><span style=3D"color:#008">operator</span><span style=
=3D"color:#000"> </span><span style=3D"color:#008">typename</span><span sty=
le=3D"color:#660">)();</span><span style=3D"color:#000"> </span><span style=
=3D"color:#800">// returns a tuple<int></span><span style=3D"color:#0=
00"><br><br> X</span><span style=3D"color:#660">(</span><span =
style=3D"color:#008">typename</span><span style=3D"color:#660">)(</span><sp=
an style=3D"color:#000">b</span><span style=3D"color:#660">)</span><span st=
yle=3D"color:#000"> c2</span><span style=3D"color:#660">;</span><span style=
=3D"color:#000"> </span><span style=3D"color:#800">// a C<1></span><s=
pan style=3D"color:#000"><br><br> A</span><span style=3D"color=
:#660"><</span><span style=3D"color:#000">E</span><span style=3D"color:#=
660">(</span><span style=3D"color:#000">b</span><span style=3D"color:#660">=
)></span><span style=3D"color:#000"> a</span><span style=3D"color:#660">=
;</span><span style=3D"color:#000"> </span><span style=3D"color:#800">// an=
A<C<1>></span><span style=3D"color:#000"><br> A</=
span><span style=3D"color:#660"><</span><span style=3D"color:#000">RE</s=
pan><span style=3D"color:#660">(</span><span style=3D"color:#000">b2</span>=
<span style=3D"color:#660">)></span><span style=3D"color:#000"> a2</span=
><span style=3D"color:#660">;</span><span style=3D"color:#000"> </span><spa=
n style=3D"color:#800">// an A<C2<C<1>>></span><span styl=
e=3D"color:#000"><br></span><span style=3D"color:#660">}</span></div></code=
></div><br></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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<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_94_22331594.1379954938259--
.
Author: MJanes <max.jns@gmail.com>
Date: Mon, 23 Sep 2013 10:06:12 -0700 (PDT)
Raw View
------=_Part_513_33249823.1379955972541
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Il giorno luned=EC 23 settembre 2013 18:48:58 UTC+2, inkwizyt...@gmail.com =
ha=20
scritto:
>
> I think this proposition should be simplified to allowing POD classes as=
=20
> template parameters (probably with restriction of floating points fields)=
..
> You will probably get most functionality that you want without adding new=
=20
> syntax and rules to language
>
I defintely disagree
firstly, types usable in this proposal can have much reacher interfaces=20
than pods ( consider optional, tuples, ... ), the only advantage of pods=20
being the theorical possibility of using brace init syntax, but this would=
=20
introduce its own problems and, IMO, would reduce readability; note that=20
with this mechanism the typename conversion can be defined recursively, by=
=20
reusing previously defined higher-level literal types.
second, in my view, the primary reason behind this proposal is to avoid the=
=20
drawbacks of using non-type and type parameters in template based=20
libraries, see the recent thread in this group ( "Variadic template=20
template problem: the issue with mixed types/values template parameters" )=
=20
for an example.
third, all the new stuff ( maybe, excluding the implicit subsitution=20
mechanism ) can be expressed in terms of existing entities ( a template=20
alias and a normal member function ), so no true new "rule" would be=20
introduced.=20
--=20
---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
------=_Part_513_33249823.1379955972541
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Il giorno luned=EC 23 settembre 2013 18:48:58 UTC+2, inkwi=
zyt...@gmail.com ha scritto:<blockquote class=3D"gmail_quote" style=3D"marg=
in: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><d=
iv dir=3D"ltr">I think this proposition should be simplified to allowing PO=
D classes as template parameters (probably with restriction of floating po=
ints fields).<br>You will probably get most functionality that you want wit=
hout adding new syntax and rules to language<br></div></blockquote><div><br=
>I defintely disagree<br><br>firstly, types usable in this proposal can hav=
e much reacher interfaces than pods ( consider optional, tuples, ... ), the=
only advantage of pods being the theorical possibility of using brace init=
syntax, but this would introduce its own problems and, IMO, would reduce r=
eadability; note that with this mechanism the typename conversion can be de=
fined recursively, by reusing previously defined higher-level literal types=
..<br><br>second, in my view, the primary reason behind this proposal is to =
avoid the drawbacks of using non-type and type parameters in template based=
libraries, see the recent thread in this group ( "Variadic template templa=
te problem: the issue with mixed types/values template parameters" ) for an=
example.<br><br>third, all the new stuff ( maybe, excluding the implicit s=
ubsitution mechanism ) can be expressed in terms of existing entities ( a t=
emplate alias and a normal member function ), so no true new "rule" would b=
e introduced. <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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<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_513_33249823.1379955972541--
.
Author: Jens Maurer <Jens.Maurer@gmx.net>
Date: Mon, 14 Oct 2013 22:54:05 +0200
Raw View
On 09/22/2013 03:12 PM, MJanes wrote:
> the aim is to "implicitly convert" an object of literal type into a
> type encoding some compile-time state. Consider,
This seems to be some kind of syntactic sugar.
What's the equivalent usage syntax with and without that syntactic sugar?
Why is that usage sufficiently prevalent and icky to warrant a core
language extension?
(Non-type template parameters won't go away with this, I'd guess,
since "5" appears to be mapped to std::integral_constant<int, 5>.)
What's the abstract mapping provided by the "operator typename"?
Supposedly, it's constant value -> type .
Why is that a "member" of the constant value, as opposed to a
"constructor" for the type? Or even a free meta-function?
Thanks,
Jens
--
---
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/.
.
Author: MJanes <max.jns@gmail.com>
Date: Tue, 15 Oct 2013 00:38:41 -0700 (PDT)
Raw View
------=_Part_41_4001728.1381822721661
Content-Type: text/plain; charset=ISO-8859-1
>
> This seems to be some kind of syntactic sugar.
>
yes it is
What's the equivalent usage syntax with and without that syntactic sugar?
>
use a value expression where a type-id is expected. So,
instead of my_template<std::integral_constant<int,5>> you write
my_template<5>,
instead of
my_template<std::tuple<std::integral_constant<int,5>,mystring<'h','a','l','l','o'>>>
you write my_template<make_tuple(5,"hallo"_myliteral)>,
etc...
Why is that usage sufficiently prevalent and icky to warrant a core
> language extension?
(Non-type template parameters won't go away with this, I'd guess,
> since "5" appears to be mapped to std::integral_constant<int, 5>.)
>
the aim is twofold:
1) generalize non-type template parameters to any literal type. But,
instead of actually allowing such non-type template parameters ( which
seems not possible due to name mangling difficulties ) we allow turning
literal objects into types during template instantiation. Yes, "usual"
non-type template parameter would not be replaced, they would remain as
basic building blocks for making higher level constructs, hence fading away
<by usage>, in the same way pointers became hidden beneath std::vector-like
interfaces.
2) uniformize type and non-type template parameters; in other words,
library authors adopting such a language feature would not <use> non-type
template parameters anymore, just types ( the template< int N > class
mytemplate; would just take an integral_constant-like type instead; users
would still instantiate the thing as before ). This has the advantage of
make template code less redundant ( say, see boost MPL and the int_,
integral_constant variants ), more general and flexible ( a template
template parameter V<T,W> would match <essentially any> binary class
template ) and simpler TMP ( no need to consider two kind of template
params, or to forcibly limit a library facility to one of them ).
What's the abstract mapping provided by the "operator typename"?
> Supposedly, it's constant value -> type .
>
yes, it is. Recapitulating, the machinery works in two phases; the easy one
( the actual operator typename declaration ) is just a compact symtax to
declare a template alias and a (constexpr) zero-ary member function
template< ... >
using optypename_alias = ...;
constexpr auto optypename_func() -> ... { ... }
the supposedly hard part, is to replace any value expression t of literal
type T appearing where a type id is expected, with something like
....A<t>...
// --->
constexpr auto r{ t.optypename_func() }; // in the first enclosing viable
scope
....A< T::optypename_alias< get<0>(r), get<1>(r), ..., get<
tuple_size<decltype(r)>::value - 1 >(r) > >...
recursively.
Why is that a "member" of the constant value, as opposed to a
> "constructor" for the type? Or even a free meta-function?
>
because, conceptually and practically, the operator typename ( or whatever
syntax one chooses ) is a pair of members: a template alias and a member
function.
ah, thank you for the reply !
--
---
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_41_4001728.1381822721661
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><blockquote style=3D"margin: 0px 0px 0px 0.8ex; border-lef=
t: 1px solid rgb(204, 204, 204); padding-left: 1ex;" class=3D"gmail_quote">=
This seems to be some kind of syntactic sugar.<br></blockquote><br>yes it i=
s<br><br><blockquote style=3D"margin: 0px 0px 0px 0.8ex; border-left: 1px s=
olid rgb(204, 204, 204); padding-left: 1ex;" class=3D"gmail_quote">What's t=
he equivalent usage syntax with and without that syntactic sugar?<br></bloc=
kquote><br>use a value expression where a type-id is expected. So, <br><br>=
instead of my_template<std::integral_constant<int,5>> you write=
my_template<5>,<br>instead of my_template<std::tuple<std::inte=
gral_constant<int,5>,mystring<'h','a','l','l','o'>>> you =
write my_template<make_tuple(5,"hallo"_myliteral)>,<br>etc...<br><br>=
<blockquote style=3D"margin: 0px 0px 0px 0.8ex; border-left: 1px solid rgb(=
204, 204, 204); padding-left: 1ex;" class=3D"gmail_quote">Why is that usage=
sufficiently prevalent and icky to warrant a core<br>language extension?&n=
bsp;</blockquote><blockquote style=3D"margin: 0px 0px 0px 0.8ex; border-lef=
t: 1px solid rgb(204, 204, 204); padding-left: 1ex;" class=3D"gmail_quote">=
(Non-type template parameters won't go away with this, I'd guess,<br>since =
"5" appears to be mapped to std::integral_constant<int, 5>.)<br></blo=
ckquote><br>the aim is twofold:<br><br>1) generalize non-type template para=
meters to any literal type. But, instead of actually allowing such non-type=
template parameters ( which seems not possible due to name mangling diffic=
ulties ) we allow turning literal objects into types during template instan=
tiation. Yes, "usual" non-type template parameter would not be replaced, th=
ey would remain as basic building blocks for making higher level constructs=
, hence fading away <by usage>, in the same way pointers became hidde=
n beneath std::vector-like interfaces.<br><br>2) uniformize type and non-ty=
pe template parameters; in other words, library authors adopting such a lan=
guage feature would not <use> non-type template parameters anymore, j=
ust types ( the template< int N > class mytemplate; would just take a=
n integral_constant-like type instead; users would still instantiate the th=
ing as before ). This has the advantage of make template code less redundan=
t ( say, see boost MPL and the int_, integral_constant variants ), more gen=
eral and flexible ( a template template parameter V<T,W> would match =
<essentially any> binary class template ) and simpler TMP ( no need t=
o consider two kind of template params, or to forcibly limit a library faci=
lity to one of them ).<br><br><blockquote style=3D"margin: 0px 0px 0px 0.8e=
x; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;" class=3D"=
gmail_quote">What's the abstract mapping provided by the "operator typename=
"?<br>Supposedly, it's constant value -> type .<br></blockqu=
ote><br>yes, it is. Recapitulating, the machinery works in two phases; the =
easy one ( the actual operator typename declaration ) is just a compact sym=
tax to declare a template alias and a (constexpr) zero-ary member function<=
br><br>template< ... ><br>using optypename_alias =3D ...;<br><br>cons=
texpr auto optypename_func() -> ... { ... }<br><br>the supposedly hard p=
art, is to replace any value expression t of literal type T appearing where=
a type id is expected, with something like<br><br>...A<t>...<br><br>=
// ---><br><br>constexpr auto r{ t.optypename_func() }; // in the first =
enclosing viable scope<br><br>...A< T::optypename_alias< get<0>=
(r), get<1>(r), ..., get< tuple_size<decltype(r)>::value - 1=
>(r) > >...<br><br>recursively.<br><br><blockquote style=3D"margi=
n: 0px 0px 0px 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-le=
ft: 1ex;" class=3D"gmail_quote">Why is that a "member" of the constant valu=
e, as opposed to a<br>"constructor" for the type? Or even a free meta=
-function?<br></blockquote><br>because, conceptually and practically, the o=
perator typename ( or whatever syntax one chooses ) is a pair of members: a=
template alias and a member function.<br><br><br>ah, thank you for the rep=
ly !</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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<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_41_4001728.1381822721661--
.
Author: Jens Maurer <Jens.Maurer@gmx.net>
Date: Wed, 16 Oct 2013 22:57:31 +0200
Raw View
On 10/15/2013 09:38 AM, MJanes wrote:
> What's the equivalent usage syntax with and without that syntactic sugar?
>
>
> use a value expression where a type-id is expected. So,
>
> instead of my_template<std::integral_constant<int,5>> you write my_template<5>,
> instead of my_template<std::tuple<std::integral_constant<int,5>,mystring<'h','a','l','l','o'>>> you write my_template<make_tuple(5,"hallo"_myliteral)>,
> etc...
And, for your examples, my_template is declared as
template<class T>
class my_template;
?
If so, instead of messing with these gymnastics of values hiding as types,
shouldn't we just allow trivial types without operator== for non-type template
parameters?
struct Data
{
int x;
char c[5];
};
template<Data value>
class my_template;
my_template<Data{ 5, 'h', 'a', 'l', 'l', 'o' }>
This seems to be much more straightforward.
> Why is that usage sufficiently prevalent and icky to warrant a core
> language extension?
>
> (Non-type template parameters won't go away with this, I'd guess,
> since "5" appears to be mapped to std::integral_constant<int, 5>.)
>
>
> the aim is twofold:
>
> 1) generalize non-type template parameters to any literal type. But,
> instead of actually allowing such non-type template parameters (
> which seems not possible due to name mangling difficulties )
Why? The major challenge is user-defined operator==, but once
you prohibit that, I can't see a problem.
> we allow
> turning literal objects into types during template instantiation.
> Yes, "usual" non-type template parameter would not be replaced, they
> would remain as basic building blocks for making higher level
> constructs, hence fading away <by usage>, in the same way pointers
> became hidden beneath std::vector-like interfaces.
> 2) uniformize type and non-type template parameters; in other words,
> library authors adopting such a language feature would not <use>
> non-type template parameters anymore, just types ( the template< int
> N > class mytemplate; would just take an integral_constant-like type
> instead; users would still instantiate the thing as before ).
Why is that useful? Types and values are fundamentally
different things, I'd say.
> This
> has the advantage of make template code less redundant ( say, see
> boost MPL and the int_, integral_constant variants ), more general
> and flexible ( a template template parameter V<T,W> would match
> <essentially any> binary class template ) and simpler TMP ( no need
> to consider two kind of template params, or to forcibly limit a
> library facility to one of them ).
I'd prefer to attack any (perceived or real) issues with writing
metaprogramming libraries directly, rather than forcing clients
of such libraries to re-write their templates in a novel way.
> What's the abstract mapping provided by the "operator typename"?
> Supposedly, it's constant value -> type .
>
>
> yes, it is. Recapitulating, the machinery works in two phases; the
> easy one ( the actual operator typename declaration ) is just a
> compact symtax to declare a template alias and a (constexpr) zero-ary
> member function
>
> template< ... >
> using optypename_alias = ...;
>
> constexpr auto optypename_func() -> ... { ... }
>
> the supposedly hard part, is to replace any value expression t of
> literal type T appearing where a type id is expected, with something
> like
>
> ...A<t>...
>
> // --->
>
> constexpr auto r{ t.optypename_func() }; // in the first enclosing viable scope
You've shown a conversion from "5" to std::integral_constant<int,5>. How are
you going to call a member function of "5" or refer to a member type of such?
> ...A< T::optypename_alias< get<0>(r), get<1>(r), ..., get< tuple_size<decltype(r)>::value - 1 >(r) > >...
>
> recursively.
>
> Why is that a "member" of the constant value, as opposed to a
> "constructor" for the type? Or even a free meta-function?
>
>
> because, conceptually and practically, the operator typename ( or
> whatever syntax one chooses ) is a pair of members: a template alias
> and a member function.
In general, no, because that won't work for scalar (built-in) types.
Jens
--
---
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/.
.
Author: MJanes <max.jns@gmail.com>
Date: Thu, 17 Oct 2013 01:25:16 -0700 (PDT)
Raw View
------=_Part_378_2594506.1381998316948
Content-Type: text/plain; charset=ISO-8859-1
>
> And, for your examples, my_template is declared as template<class T> class
> my_template; ?
>
yes, it is
If so, instead of messing with these gymnastics of values hiding as
> types[...]
> This seems to be much more straightforward.[...] Why? The major challenge
> is
> user-defined operator==, but once you prohibit that, I can't see a problem.
>
sure, but at the cost of a loss of generality and flexibility ( see below
.... )
Types and values are fundamentally different things, I'd say.
>
maybe, but c++ already essentially defines a one-to-one correpondence
between constexpr values and types:
int i --> integral_constant<int,i>
value expression t of type T --> some_template<T,t>, whenever t is allowed
as a non-type param
....
when this bijection is semantical ( eg. int <-> integral_constant )
constant values and types encoding them
essentially becomes syntactical variants, that is being essentially the
same thing. This proposal renders this
bijection manifest at the syntax level.
Why is that useful?
>
again, see below for further examples. In general terms, whenever you write
a class template taking some kind of
"value parameter", you're faced with the design problem of deciding if 1)
it should be type or non-type and
2) if non-type, which one ( int,float,etc... ) ?
sure, this decision has little impact on the way the class template is
defined ( at worst, one can choose to forward
everything to a internal class template taking only type parameters ).
But, it has an impact on the way the class template is used.
For example, what if you want to support both a type and a non-type ? what
if you want to support non-type of different
types ? ( = you need to expose two or more variants of the same class
template, provided it's possible at all )
what if you want to match ( say, while specializing or overloading ) a
class template A<T,...> taking one or more arguments
unregarding of whether they are types or non-types ? ( note that there
could be undocumented default template arguments, as in the STL )
you say that non-type parameters are fundamentally different from type
parameters, I'd argue that 99% of the times this distinction is artificial,
in the sense that one could swap them without changing the meaning of the
class template, just the way users instantiate them would change ( the only
exception being things like integral_constant themselves, of course ).
this proposal would allow library writers to always use ( and assume other
libraries use ) types, by exploiting a semantical bijection that often
already exists.
Moreover, expressions allowed for constexpr values are different from those
allowed for types, this opens the way for more EDSL at the instantiation
site, with no impact on the way the class template is defined ( again, see
below ).
>> You've shown a conversion from "5" to std::integral_constant<int,5>. How
are
>> you going to call a member function of "5" or refer to a member type of
such?
>> [...] In general, no, because that won't work for scalar (built-in)
types.
primitive types would have "canonical" operator typename implementation, in
the same way other operators have
( user defined operator= must be a member, nonetheless, primitive types can
be assigned, can't they ? ).
also, I didn't mentioned another reason why user-defined operator typename
should be members: the correspondence
constexpr value<->type must be 1) a property of the value type and 2)
depends on the notion of identity of the value type, in other words, it
must be encapsualted in the same operator= ( and to a less extent
operator== ) is.
Finally, here is some off-the-top-of-my-head examples of what you can do
with this ( and you could't even with POD non-type parameters ):
1) given a "metastring" literal, pass strings of arbitrary length to
templates: t<"hallo"ms>; among other things, this would be useful for (
still hypothetical ) compile reflection or the like. Of course, this would
work with any literal type. AFAIK, currently, you need to wrap the thing
with decltype or a macro to accomplish the same goal.
2) suppose you have a class template taking "numerical" parameters, say, a
simple_histogram<T,bin1,bin2,...> class used to compute a stack-allocated
histogram with compile time specified "bins" counting T's. Now, I want the
bin specification to support any ( eventually mixed ) strictly weakly
ordered compile time numeric ( for example, when bins ( and T ) have
integer types it would give exactness guarantees, whereas for floating not
). Users would just write simple_histogram<int,1,2,3> or
simple_histogram<int,1,2,3.5> or simple_histogram<mytype,myvalue,....>, and
the library author would just declare a single class template <typename T,
typename... Bins> simple_histogram; moreover, note that the requirements of
the bins could be concept-lite-checked int this case.
3) speaking of EDSL's, one could take a different approach to expression
templates:
constexpr label<1> A;
constexpr label<2> B;
evaluator< A * B * ( A^-1 ) - 2 * B > some_sensible_name; // any natural
notation algebraic expression
auto a = some_specific_algebra_element{ ... };
auto b = some_other_specific_algebra_element{ ... };
some_sensible_name(a,b) // if legal, compute the expression with the best
possible algorithm given a,b types
as of now, the best you can do is some variant of "evaluator<decltype( A *
B * ( A^s<-1>() ) - s<2>() * B ) >", losing natural notation ...
4) as another (really-mini-)EDSL example, consider a compile time graph
class template:
template< typename V, typename W >
edge;
template< typename... T >
graph;
where T can be any type ( representing a vertex ) or an edge<V,W> ( with
V,W being verteces );
now, given a "vertex label" literal ""v representing some vertex label
(say, an integer), with little effort we could write
graph< 1v, 2v, 3v, 1v - 2v, 3v - 1v >
instead of
graph<vertex<1>,vertex<2>,vertex<3>,edge<vertex<1>,vertex<2>>,edge<vertex<3>,vertex<1>>>
the template parameters are still of "type" type, so we can also write, say
graph<T,V,W,edge<T,V>,edge<W,V>>
or even invent a metafunction transparently working on any labeled graph:
labeled_graph<
graph< 1v, 2v, 3v, 1v - 2v, 3v - 1v >, // act as a skeleton to ease the
specification of the graph topology
label<1v,T>,
label<2v,V>,
label<3v,W>
>
to some extent, this has also the effect of decoupling the instantation
syntax from the class template.
ah, sorry for the lengthy post :)
--
---
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_378_2594506.1381998316948
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><blockquote style=3D"margin: 0px 0px 0px 0.8ex; border-lef=
t: 1px solid rgb(204, 204, 204); padding-left: 1ex;" class=3D"gmail_quote">=
And, for your examples, my_template is declared as template<class T> =
class my_template; ?<br></blockquote><br>yes, it is<br><br><blockquote styl=
e=3D"margin: 0px 0px 0px 0.8ex; border-left: 1px solid rgb(204, 204, 204); =
padding-left: 1ex;" class=3D"gmail_quote">If so, instead of messing with th=
ese gymnastics of values hiding as types[...]<br>This seems to be much more=
straightforward.[...] Why? The major challenge is<br>user-defined op=
erator=3D=3D, but once you prohibit that, I can't see a problem.<br></block=
quote><br>sure, but at the cost of a loss of generality and flexibility ( s=
ee below ... )<br><br><blockquote style=3D"margin: 0px 0px 0px 0.8ex; borde=
r-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;" class=3D"gmail_qu=
ote">Types and values are fundamentally different things, I'd say.<br></blo=
ckquote><br>maybe, but c++ already essentially defines a one-to-one correpo=
ndence between constexpr values and types:<br><br>int i --> integral_con=
stant<int,i><br>value expression t of type T --> some_template<=
T,t>, whenever t is allowed as a non-type param<br>...<br><br>when this =
bijection is semantical ( eg. int <-> integral_constant ) constant va=
lues and types encoding them<br>essentially becomes syntactical variants, t=
hat is being essentially the same thing. This proposal renders this<br>bije=
ction manifest at the syntax level.<br><br><blockquote style=3D"margin: 0px=
0px 0px 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1e=
x;" class=3D"gmail_quote">Why is that useful?<br></blockquote><br>again, se=
e below for further examples. In general terms, whenever you write a class =
template taking some kind of<br>"value parameter", you're faced with the de=
sign problem of deciding if 1) it should be type or non-type and<br>2) if n=
on-type, which one ( int,float,etc... ) ?<br><br>sure, this decision has li=
ttle impact on the way the class template is defined ( at worst, one can ch=
oose to forward<br>everything to a internal class template taking only type=
parameters ).<br>But, it has an impact on the way the class template=
is used.<br>For example, what if you want to support both a type and a non=
-type ? what if you want to support non-type of different<br>types ? ( =3D =
you need to expose two or more variants of the same class template, provide=
d it's possible at all )<br>what if you want to match ( say, while speciali=
zing or overloading ) a class template A<T,...> taking one or more ar=
guments<br>unregarding of whether they are types or non-types ? ( note that=
there could be undocumented default template arguments, as in the STL )<br=
><br>you say that non-type parameters are fundamentally different from type=
parameters, I'd argue that 99% of the times this distinction is artificial=
, in the sense that one could swap them without changing the meaning of the=
class template, just the way users instantiate them would change ( the onl=
y exception being things like integral_constant themselves, of course ).<br=
><br>this proposal would allow library writers to always use ( and assume o=
ther libraries use ) types, by exploiting a semantical bijection that often=
already exists.<br>Moreover, expressions allowed for constexpr values are =
different from those allowed for types, this opens the way for more EDSL at=
the instantiation site, with no impact on the way the class template is de=
fined ( again, see below ).<br><br>>> You've shown a conversion from =
"5" to std::integral_constant<int,5>. How are<br>>> you going t=
o call a member function of "5" or refer to a member type of such?<br>>&=
gt; [...] In general, no, because that won't work for scalar (built-in) typ=
es.<br><br>primitive types would have "canonical" operator typename impleme=
ntation, in the same way other operators have<br>( user defined operator=3D=
must be a member, nonetheless, primitive types can be assigned, can't they=
? ).<br><br>also, I didn't mentioned another reason why user-defined opera=
tor typename should be members: the correspondence<br>constexpr value<-&=
gt;type must be 1) a property of the value type and 2) depends on the notio=
n of identity of the value type, in other words, it must be encapsualted in=
the same operator=3D ( and to a less extent operator=3D=3D ) is.<br><br><b=
r><br>Finally, here is some off-the-top-of-my-head examples of what you can=
do with this ( and you could't even with POD non-type parameters ):<br><br=
>1) given a "metastring" literal, pass strings of arbitrary length to templ=
ates: t<"hallo"ms>; among other things, this would be useful for ( st=
ill hypothetical ) compile reflection or the like. Of course, this would wo=
rk with any literal type. AFAIK, currently, you need to wrap the thing with=
decltype or a macro to accomplish the same goal.<br><br>2) suppose you hav=
e a class template taking "numerical" parameters, say, a simple_histogram&l=
t;T,bin1,bin2,...> class used to compute a stack-allocated histogram wit=
h compile time specified "bins" counting T's. Now, I want the bin specifica=
tion to support any ( eventually mixed ) strictly weakly ordered compile ti=
me numeric ( for example, when bins ( and T ) have integer types it would g=
ive exactness guarantees, whereas for floating not ). Users would just writ=
e simple_histogram<int,1,2,3> or simple_histogram<int,1,2,3.5> =
or simple_histogram<mytype,myvalue,....>, and the library author woul=
d just declare a single class template <typename T, typename... Bins>=
simple_histogram; moreover, note that the requirements of the bins could b=
e concept-lite-checked int this case.<br><br>3) speaking of EDSL's, one cou=
ld take a different approach to expression templates:<br><br>constexpr labe=
l<1> A;<br>constexpr label<2> B;<br><br>evaluator< A * B * (=
A^-1 ) - 2 * B > some_sensible_name; // any natural notation algebraic =
expression<br><br>auto a =3D some_specific_algebra_element{ ... };<br>auto =
b =3D some_other_specific_algebra_element{ ... };<br><br>some_sensible_name=
(a,b) // if legal, compute the expression with the best possible algorithm =
given a,b types<br><br>as of now, the best you can do is some variant of "e=
valuator<decltype( A * B * ( A^s<-1>() ) - s<2>() * B ) >=
", losing natural notation ...<br><br>4) as another (really-mini-)EDSL exam=
ple, consider a compile time graph class template:<br><br>template< type=
name V, typename W ><br>edge;<br><br>template< typename... T ><br>=
graph;<br><br>where T can be any type ( representing a vertex ) or an edge&=
lt;V,W> ( with V,W being verteces );<br>now, given a "vertex label" lite=
ral ""v representing some vertex label (say, an integer), with little=
effort we could write<br><br>graph< 1v, 2v, 3v, 1v - 2v, 3v - 1v ><b=
r><br>instead of<br><br>graph<vertex<1>,vertex<2>,vertex<=
3>,edge<vertex<1>,vertex<2>>,edge<vertex<3>,v=
ertex<1>>><br><br>the template parameters are still of "type" t=
ype, so we can also write, say<br><br>graph<T,V,W,edge<T,V>,edge&l=
t;W,V>><br><br>or even invent a metafunction transparently working on=
any labeled graph:<br><br>labeled_graph<<br> graph<=
; 1v, 2v, 3v, 1v - 2v, 3v - 1v >, // act as a skeleton to ease the speci=
fication of the graph topology<br> label<1v,T>,<br>=
label<2v,V>,<br> label<3v,W&g=
t;<br> ><br><br>to some extent, this has also the effe=
ct of decoupling the instantation syntax from the class template.<br><br>ah=
, sorry for the lengthy post :)<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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<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_378_2594506.1381998316948--
.