Topic: add an implicit const char* literal() function
Author: "S.B." <i.and.my.little.friends@gmail.com>
Date: Mon, 13 Jul 2015 02:07:51 -0700 (PDT)
Raw View
------=_Part_745_795042674.1436778472062
Content-Type: multipart/alternative;
boundary="----=_Part_746_1195357311.1436778472062"
------=_Part_746_1195357311.1436778472062
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
It looks like a kind of reflection. According to my understanding, the=20
function that you purposed can be implemented with the=20
`std::enum_traits<E>::enumerators::get<I>::identifier` which was purposed=
=20
in N4428 <http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2015/n4428.pdf=
>
..
=E5=9C=A8 2015=E5=B9=B47=E6=9C=8813=E6=97=A5=E6=98=9F=E6=9C=9F=E4=B8=80 UTC=
+8=E4=B8=8B=E5=8D=884:17:44=EF=BC=8CFrancis Andre=E5=86=99=E9=81=93=EF=BC=
=9A
>
> Hi=20
>
> I am proposing to add a implicit member function to the enum type or=20
> enum class type whose purpose would be to return the literal used to=20
> define each enumerated value. For example=20
>
> enum class Color { red, blue, yellow};=20
> Color color =3D Color::yellow;=20
>
> cout << "color=3D" << color.literal() << endl;=20
>
> would output=20
>
> color=3Dyellow=20
>
> 1/ the literal fonction could be produced automaticaly by the compiler:=
=20
> const char* literal();=20
> 2/ it should be generated only if it is referenced in the user's code=20
> 3/ when the value of the enum type variable is out of the range of the=20
> enumerated value, the returned string could be "???" since "???" is not=
=20
> a acceptable name for a enumerated.=20
> 4/ It does not break any previous code=20
>
> The main interest of this function is to ligthen the explicitation of=20
> the encoding of an user's defined enum, specificaly when the enum has a=
=20
> large number of values.=20
>
> FA=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_746_1195357311.1436778472062
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br>It looks like a kind of reflection. According to my un=
derstanding, the function that you purposed can be implemented with the `st=
d::enum_traits<E>::enumerators::get<I>::identifier` which was p=
urposed in <a href=3D"http://www.open-std.org/JTC1/SC22/WG21/docs/papers/20=
15/n4428.pdf">N4428</a>.<br><br>=E5=9C=A8 2015=E5=B9=B47=E6=9C=8813=E6=97=
=A5=E6=98=9F=E6=9C=9F=E4=B8=80 UTC+8=E4=B8=8B=E5=8D=884:17:44=EF=BC=8CFranc=
is Andre=E5=86=99=E9=81=93=EF=BC=9A<blockquote class=3D"gmail_quote" style=
=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: =
1ex;">Hi
<br>
<br>I am proposing to add a implicit member function to the enum type or=20
<br>enum class type whose purpose would be to return the literal used to=20
<br>define each enumerated value. For example
<br>
<br>enum class Color { red, blue, yellow};
<br>Color color =3D Color::yellow;
<br>
<br>cout << "color=3D" << color.literal() =C2=A0<&=
lt; endl;
<br>
<br>would output
<br>
<br>color=3Dyellow
<br>
<br>1/ the literal fonction could be produced automaticaly by the compiler:=
=20
<br>const char* literal();
<br>2/ it should be generated only if it is referenced in the user's co=
de
<br>3/ when the value of the enum type variable is out of the range of the=
=20
<br>enumerated value, the returned string could be "???" since &q=
uot;???" is not=20
<br>a acceptable name for a enumerated.
<br>4/ It does not break any previous code
<br>
<br>The main interest of this function is to ligthen the explicitation of=
=20
<br>the encoding of an user's defined enum, specificaly when the enum h=
as a=20
<br>large number of values.
<br>
<br>FA
<br></blockquote></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_746_1195357311.1436778472062--
------=_Part_745_795042674.1436778472062--
.