Topic: template metaclass?


Author: euloanty@live.com
Date: Sun, 11 Feb 2018 15:02:31 -0800 (PST)
Raw View
------=_Part_5722_928345133.1518390151291
Content-Type: multipart/alternative;
 boundary="----=_Part_5723_1180407939.1518390151291"

------=_Part_5723_1180407939.1518390151291
Content-Type: text/plain; charset="UTF-8"




I watched Herb Sutter's cppcon video about metaclasses and read his
proposal about metaclass. It is a great video.

<https://lh3.googleusercontent.com/-dAcmTZ1P5UU/WoDLN7MODhI/AAAAAAAAAEY/znSYUuDjAYsLcb9Lh-FdKt_JxCCcTQGagCLcBGAs/s1600/c1.PNG>

However, I think he missed a huge part of his proposal which is template
metaclass or concept metaclass.

template<class T>
$class basic_enum:value
{
 constexpr
 {
  compiler.require(....

  ->{using U = T; }
 }
};
template<class T>
$class flag_enum:basic_enum<T>
{
};
flag_enum<int> int_fruit
{
 apple,banana,orange
};
flag_enum<std::size_t> size_t_fruit  //flag enum based on std::size_t
{
 apple,banana,orange
};
template<typename T>
flag_enum<T> fruit  //flag enum based on T
{
 apple,banana,orange
};
fruit<std::size_t>; //flag enum based on std::size_t
fruit<std::size_t> is just the same as size_t_fruit;
template<std::UnsignedInteger T>
flag_enum<T> fruit  //flag enum based on T. T must satisfy unsigned_intger
concept
{
 apple,banana,orange
};

or just write this into the template metaclass directly:

template<std::UnsignedInteger T>
$class basic_enum:value
{
 constexpr
 {
  compiler.require(....

  ->{using U = T; }
 }
};


What about metaclass as template parameter? or metaclass as concept
parameter? Template Metaclass Metaclass?

template<UnsignedInteger T>
$class flag_enum
{
....
};
template<$class E>
$basic_enum<$E> apple
{
};
$basic_enum<$flag_enum<std::size_t>> std::size_t_apple;
template<$param_must_be_unsigned T>
$class flag_enum
{
....
};




--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/8fff5d9f-a85e-42d5-ad10-346cdb415095%40isocpp.org.

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

<div dir=3D"ltr"><p class=3D"separator" style=3D"text-align: center; clear:=
 both;"><font color=3D"#000020"><br></font></p><div>I watched Herb Sutter&#=
39;s cppcon video about metaclasses and read his proposal about metaclass. =
It is a great video.</div><p class=3D"separator" style=3D"text-align: cente=
r; clear: both;"><a style=3D"margin-right: 1em; margin-left: 1em;" href=3D"=
https://lh3.googleusercontent.com/-dAcmTZ1P5UU/WoDLN7MODhI/AAAAAAAAAEY/znSY=
UuDjAYsLcb9Lh-FdKt_JxCCcTQGagCLcBGAs/s1600/c1.PNG" imageanchor=3D"1"><img w=
idth=3D"320" height=3D"138" src=3D"https://lh3.googleusercontent.com/-dAcmT=
Z1P5UU/WoDLN7MODhI/AAAAAAAAAEY/znSYUuDjAYsLcb9Lh-FdKt_JxCCcTQGagCLcBGAs/s32=
0/c1.PNG" border=3D"0"></a></p><div><br></div><div>However, I think he miss=
ed a huge part of his proposal which is template metaclass or concept metac=
lass.</div><div><br></div><div class=3D"prettyprint" style=3D"border: 1px s=
olid rgb(187, 187, 187); word-wrap: break-word; background-color: rgb(250, =
250, 250);"><code class=3D"prettyprint"><div class=3D"subprettyprint"><span=
 class=3D"styled-by-prettify" style=3D"color: #606;"><font color=3D"#004000=
" face=3D"Arial" style=3D"background-color: transparent;">template&lt;class=
 T&gt;<br>$class basic_enum:value<br>{<br>=C2=A0constexpr<br>=C2=A0{<br>=C2=
=A0=C2=A0compiler.require(....<br>=C2=A0=C2=A0<br>=C2=A0=C2=A0-&gt;{using U=
 =3D T; }<br>=C2=A0}<br>};</font></span></div><div class=3D"subprettyprint"=
><span class=3D"styled-by-prettify" style=3D"color: #606;"><font color=3D"#=
004000" face=3D"Arial" style=3D"background-color: transparent;">template&lt=
;class T&gt;<br>$class flag_enum:basic_enum&lt;T&gt;<br>{<br>};</font></spa=
n></div><div class=3D"subprettyprint"><span class=3D"styled-by-prettify" st=
yle=3D"color: #606;"><font color=3D"#004000" face=3D"Arial" style=3D"backgr=
ound-color: transparent;">flag_enum&lt;int&gt; int_fruit<br>{<br>=C2=A0appl=
e,banana,orange<br>};</font></span></div><div class=3D"subprettyprint"><spa=
n class=3D"styled-by-prettify" style=3D"color: #606;"><font color=3D"#00400=
0" face=3D"Arial" style=3D"background-color: transparent;">flag_enum&lt;std=
::size_t&gt; size_t_fruit=C2=A0=C2=A0//flag enum based on std::size_t<br>{<=
br>=C2=A0apple,banana,orange<br>};</font></span></div><div class=3D"subpret=
typrint"><span class=3D"styled-by-prettify" style=3D"color: #606;"><font co=
lor=3D"#004000" face=3D"Arial" style=3D"background-color: transparent;">tem=
plate&lt;typename T&gt;<br>flag_enum&lt;T&gt; fruit=C2=A0=C2=A0//flag enum =
based on T<br>{<br>=C2=A0apple,banana,orange<br>};</font></span></div><div =
class=3D"subprettyprint"><span class=3D"styled-by-prettify" style=3D"color:=
 #606;"><font color=3D"#004000" face=3D"Arial" style=3D"background-color: t=
ransparent;">fruit&lt;std::size_t&gt;;=C2=A0//flag enum based on std::size_=
t</font></span></div><div class=3D"subprettyprint"><span class=3D"styled-by=
-prettify" style=3D"color: #606;"><font color=3D"#004000" face=3D"Arial" st=
yle=3D"background-color: transparent;">fruit&lt;std::size_t&gt; is just the=
 same as size_t_fruit;</font></span></div><div class=3D"subprettyprint"><sp=
an class=3D"styled-by-prettify" style=3D"color: #606;"><font color=3D"#0040=
00" face=3D"Arial" style=3D"background-color: transparent;">template&lt;std=
::UnsignedInteger T&gt;<br>flag_enum&lt;T&gt; fruit=C2=A0=C2=A0//flag enum =
based on T. T must satisfy unsigned_intger concept<br>{<br>=C2=A0apple,bana=
na,orange<br>};<br></font></span><span class=3D"styled-by-prettify" style=
=3D"color: #660;"></span></div></code></div><div><br>or just write this int=
o the template metaclass directly:</div><div><br></div><div class=3D"pretty=
print" style=3D"border: 1px solid rgb(187, 187, 187); word-wrap: break-word=
; background-color: rgb(250, 250, 250);"><code class=3D"prettyprint"><div c=
lass=3D"subprettyprint"><span class=3D"styled-by-prettify" style=3D"color: =
#606;"><font color=3D"#004000" face=3D"Arial" style=3D"background-color: tr=
ansparent;">template&lt;std::UnsignedInteger T&gt;<br>$class basic_enum:val=
ue<br>{<br>=C2=A0constexpr<br>=C2=A0{<br>=C2=A0=C2=A0compiler.require(....<=
br>=C2=A0=C2=A0<br>=C2=A0=C2=A0-&gt;{using U =3D T; }<br>=C2=A0}<br>};</fon=
t></span><span class=3D"styled-by-prettify" style=3D"color: #660;"></span><=
/div></code></div><div><br></div><div><br></div><div>What about metaclass a=
s template parameter? or metaclass as concept parameter? Template Metaclass=
 Metaclass?</div><div><br></div><div><div class=3D"prettyprint" style=3D"bo=
rder: 1px solid rgb(187, 187, 187); word-wrap: break-word; background-color=
: rgb(250, 250, 250);"><code class=3D"prettyprint"><div class=3D"subprettyp=
rint"><span class=3D"styled-by-prettify" style=3D"color: #606;"><font color=
=3D"#004000" face=3D"Arial" style=3D"background-color: transparent;">templa=
te&lt;UnsignedInteger T&gt;<br>$class flag_enum<br>{<br>...<br>};</font></s=
pan></div><div class=3D"subprettyprint"><span class=3D"styled-by-prettify" =
style=3D"color: #606;"><font color=3D"#004000" face=3D"Arial" style=3D"back=
ground-color: transparent;">template&lt;$class E&gt;<br>$basic_enum&lt;$E&g=
t; apple<br>{<br>};</font></span></div><div class=3D"subprettyprint"><span =
class=3D"styled-by-prettify" style=3D"color: #606;"><font color=3D"#004000"=
 face=3D"Arial" style=3D"background-color: transparent;">$basic_enum&lt;$fl=
ag_enum&lt;std::size_t&gt;&gt; std::size_t_apple;</font></span></div><div c=
lass=3D"subprettyprint"><span class=3D"styled-by-prettify" style=3D"color: =
#606;"><font color=3D"#004000" face=3D"Arial" style=3D"background-color: tr=
ansparent;">template&lt;$param_must_be_unsigned T&gt;<br>$class flag_enum<b=
r>{<br>...<br>};</font></span><span class=3D"styled-by-prettify" style=3D"c=
olor: #660;"></span></div></code></div><br><br></div><div><br><br></div></d=
iv>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/8fff5d9f-a85e-42d5-ad10-346cdb415095%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/8fff5d9f-a85e-42d5-ad10-346cdb415095=
%40isocpp.org</a>.<br />

------=_Part_5723_1180407939.1518390151291--

------=_Part_5722_928345133.1518390151291--

.