220 27969 <CA+fGSbNGsK=YXhZfmU7=JPPGvdgpJ-MwTWThQwjxiACEMy9Tvg@mail.gmail.com> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Ricardo Fabiano de Andrade <ricardofabianodeandrade@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Re: Make (strongly typed) enums castable to char
 const * const
Date: Fri, 26 Aug 2016 10:51:53 -0500
Lines: 172
Approved: news@gmane.org
Message-ID: <CA+fGSbNGsK=YXhZfmU7=JPPGvdgpJ-MwTWThQwjxiACEMy9Tvg@mail.gmail.com>
References: <87vayosip3.fsf@gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary=001a11c0360a5502c1053afb7e23
X-Trace: blaine.gmane.org 1472226720 25211 195.159.176.226 (26 Aug 2016 15:52:00 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Fri, 26 Aug 2016 15:52:00 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBCJN7V7TRQMBBGWLQG7AKGQE7QMYNCA@isocpp.org Fri Aug 26 17:51:55 2016
Return-path: <std-proposals+bncBCJN7V7TRQMBBGWLQG7AKGQE7QMYNCA@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-oi0-f71.google.com ([209.85.218.71])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBCJN7V7TRQMBBGWLQG7AKGQE7QMYNCA@isocpp.org>)
	id 1bdJQB-0005vi-4R
	for gclcip-std-proposals@m.gmane.org; Fri, 26 Aug 2016 17:51:55 +0200
Original-Received: by mail-oi0-f71.google.com with SMTP id c189sf266666686oia.1
        for <gclcip-std-proposals@m.gmane.org>; Fri, 26 Aug 2016 08:51:56 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=mime-version:in-reply-to:references:from:date:message-id:subject:to
         :x-original-sender:x-original-authentication-results:reply-to
         :precedence:mailing-list:list-id:x-spam-checked-in-group:list-post
         :list-help:list-archive:list-subscribe:list-unsubscribe;
        bh=e8zUsUZ4aUwGDdZM1GpeUivVWazKsAXAgg5NkjxAmrc=;
        b=bCEl/YAXcNzdYFw2XW1Vg0/eVisu7WX0w9X1Sl8678LL4vpOWnNoQQePROVrMXW411
         ybtidXFqvIsoCGiLptgJ2ZvxLK4v2XCY5UZexdwWdEsgbNGOIE3zmtGcTuo2ccEC8ZWk
         vgWswFuwjdfHFGyVwAvF/pMDzUJjpC++Ev0lYbhdlB+21CY1mJScJJbVq7zCBidWq7IU
         NcTqG5W9sUjCIuYXJ0MrIAZFjihFAR/KwO1dLotM2sq+09cHkYCOlSXzNpJg6ZTZbNDP
         tM+isjbYaEz7P8Zw7qY9o/QKxv2PU402aIBGO0p8HBGUBm2VIUSac9tWxkem+pcocgec
         Iz8A==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:mime-version:in-reply-to:references:from:date
         :message-id:subject:to:x-original-sender
         :x-original-authentication-results:reply-to:precedence:mailing-list
         :list-id:x-spam-checked-in-group:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=e8zUsUZ4aUwGDdZM1GpeUivVWazKsAXAgg5NkjxAmrc=;
        b=JXTfB7iZ5PswNXGbVmRTnjUb6BeI4H9yniocc3kIh6pUUFnFDrOcFDQJyaza15L4VL
         58OKQKG/XZ/Hv4edPvB/5mn9znfXEa137yRNH7xh4KUWf4UmiRBKsl6cLj9mwRa6huG5
         7pu+8It2HgTBBzFxUf+8iubjqMCrybBSX5uFLVFIcZN8SFUk1UGt5vfL/9PRYJpVdaza
         I9YXMjmcnLT/VtWP9raHvltn8wHF4aSuDe2g33i1qX6wo4sl/RwgvNxzCgGYPXWYtMbS
         AWUkUETBPWHjidCGlLZDv0FsKlADTnFojpDDnc/yoMHcaHKjibqUV72duJkY9izVhRew
         +FCQ==
X-Gm-Message-State: AE9vXwMtYJj2YLNBB8a7UsIL2ls30xIRo9LLZxzLKh3Q5WtQuNsgKsBbIqOND8HyMkCx3w==
X-Received: by 10.107.130.146 with SMTP id m18mr3098177ioi.30.1472226715602;
        Fri, 26 Aug 2016 08:51:55 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.157.24.71 with SMTP id t7ls3571859ott.5.gmail; Fri, 26 Aug
 2016 08:51:54 -0700 (PDT)
X-Received: by 10.237.54.164 with SMTP id f33mr4153062qtb.139.1472226714648;
        Fri, 26 Aug 2016 08:51:54 -0700 (PDT)
Original-Received: from mail-qt0-x232.google.com (mail-qt0-x232.google.com. [2607:f8b0:400d:c0d::232])
        by mx.google.com with ESMTPS id b65si14782602qkf.1.2016.08.26.08.51.54
        for <std-proposals@isocpp.org>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Fri, 26 Aug 2016 08:51:54 -0700 (PDT)
Received-SPF: pass (google.com: domain of ricardofabianodeandrade@gmail.com designates 2607:f8b0:400d:c0d::232 as permitted sender) client-ip=2607:f8b0:400d:c0d::232;
Original-Received: by mail-qt0-x232.google.com with SMTP id u25so39842096qtb.1
        for <std-proposals@isocpp.org>; Fri, 26 Aug 2016 08:51:54 -0700 (PDT)
X-Received: by 10.200.37.129 with SMTP id e1mr4141462qte.96.1472226714252;
 Fri, 26 Aug 2016 08:51:54 -0700 (PDT)
Original-Received: by 10.140.21.234 with HTTP; Fri, 26 Aug 2016 08:51:53 -0700 (PDT)
In-Reply-To: <87vayosip3.fsf@gmail.com>
X-Original-Sender: ricardofabianodeandrade@gmail.com
X-Original-Authentication-Results: mx.google.com;       dkim=pass
 header.i=@gmail.com;       spf=pass (google.com: domain of
 ricardofabianodeandrade@gmail.com designates 2607:f8b0:400d:c0d::232 as
 permitted sender) smtp.mailfrom=ricardofabianodeandrade@gmail.com;
       dmarc=pass (p=NONE dis=NONE) header.from=gmail.com
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <std-proposals.isocpp.org>
X-Google-Group-Id: 399137483710
List-Post: <https://groups.google.com/a/isocpp.org/group/std-proposals/post>, <mailto:std-proposals@isocpp.org>
List-Help: <https://support.google.com/a/isocpp.org/bin/topic.py?topic=25838>, <mailto:std-proposals+help@isocpp.org>
List-Archive: <https://groups.google.com/a/isocpp.org/group/std-proposals/>
List-Subscribe: <https://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:std-proposals+subscribe@isocpp.org>
List-Unsubscribe: <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>,
 <https://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:27969
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/27969>

--001a11c0360a5502c1053afb7e23
Content-Type: text/plain; charset=UTF-8

The author of static reflection has been working on an implementation in
clang:
https://github.com/matus-chochlik/clang

It's still a work in progress and few things are little bit different from
the latest revision of the proposal.
But if I'm not wrong you should be able to list all the names and values
within an enum as suggested by others.


On Thu, Aug 25, 2016 at 3:21 PM, Moritz Klammler <moritz.klammler@gmail.com>
wrote:

> > The problem is that it's not a library feature. Well, not yet. Until
> > static reflection happens, it is *impossible* to implement these sorts
> > of things without either compiler magic or macros.
> >
> > And therefore, you're not really asking for a library feature. You're
> > asking for a *compiler* feature, that just so happens to be exposed
> > via the library.
>
> Yes, that's what I mean, even though I didn't spell it out very
> explicitly.
>
> > I would say that the best thing your proposal could do is be defined
> > *in terms of static reflection*. It's not so much that your proposal
> > should *require* it. But at all times, you're making sure that the
> > library interface you develop could *eventually* be implemented using
> > static reflection.
>
> I'm not the OP but I find this an interesting idea I might follow.  Do
> you happen to know of any place where we can already play with static
> reflection as currently proposed?  It would be immensely useful for this
> task.
>
> > The other thing that's important to keep in mind is that runtime
> > reflection takes up *memory*. Those strings for enums have to come
> > from somewhere.  Those arrays of enumeration values have to live
> > somewhere. Whatever library system you come up with needs to have a
> > way to deal with that. You cannot just force every enumerator in a
> > program to have runtime reflected data.
>
> Indeed.  Therefore, I think that using the template machinery for this
> would be a good thing.  If your program never instantiates
> `std::to_string<MyEnum>` (or whatever it is called), no string table of
> `MyEnum`s names has to be set aside.  And if you do instantiate it, you
> just pay for what you've explicitly asked for.  While static analysis
> could also be used to do this when implemented differently, compilers
> already do the right thing for templates so it wouldn't add extra
> complexity.
>
> --
> 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/87vayosip3.fsf%40gmail.com.
>

-- 
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/CA%2BfGSbNGsK%3DYXhZfmU7%3DJPPGvdgpJ-MwTWThQwjxiACEMy9Tvg%40mail.gmail.com.

--001a11c0360a5502c1053afb7e23
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">The author of static reflection has been working on an imp=
lementation in clang:<div><a href=3D"https://github.com/matus-chochlik/clan=
g">https://github.com/matus-chochlik/clang</a><br></div><div><br></div><div=
>It&#39;s still a work in progress and few things are little bit different =
from the latest revision of the proposal.</div><div>But if I&#39;m not wron=
g you should be able to list all the names and values within an enum as sug=
gested by others.<br></div><div><br></div></div><div class=3D"gmail_extra">=
<br><div class=3D"gmail_quote">On Thu, Aug 25, 2016 at 3:21 PM, Moritz Klam=
mler <span dir=3D"ltr">&lt;<a href=3D"mailto:moritz.klammler@gmail.com" tar=
get=3D"_blank">moritz.klammler@gmail.com</a>&gt;</span> wrote:<br><blockquo=
te class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc so=
lid;padding-left:1ex">&gt; The problem is that it&#39;s not a library featu=
re. Well, not yet. Until<br>
&gt; static reflection happens, it is *impossible* to implement these sorts=
<br>
&gt; of things without either compiler magic or macros.<br>
&gt;<br>
&gt; And therefore, you&#39;re not really asking for a library feature. You=
&#39;re<br>
&gt; asking for a *compiler* feature, that just so happens to be exposed<br=
>
&gt; via the library.<br>
<br>
Yes, that&#39;s what I mean, even though I didn&#39;t spell it out very<br>
explicitly.<br>
<br>
&gt; I would say that the best thing your proposal could do is be defined<b=
r>
&gt; *in terms of static reflection*. It&#39;s not so much that your propos=
al<br>
&gt; should *require* it. But at all times, you&#39;re making sure that the=
<br>
&gt; library interface you develop could *eventually* be implemented using<=
br>
&gt; static reflection.<br>
<br>
I&#39;m not the OP but I find this an interesting idea I might follow.=C2=
=A0 Do<br>
you happen to know of any place where we can already play with static<br>
reflection as currently proposed?=C2=A0 It would be immensely useful for th=
is<br>
task.<br>
<br>
&gt; The other thing that&#39;s important to keep in mind is that runtime<b=
r>
&gt; reflection takes up *memory*. Those strings for enums have to come<br>
&gt; from somewhere.=C2=A0 Those arrays of enumeration values have to live<=
br>
&gt; somewhere. Whatever library system you come up with needs to have a<br=
>
&gt; way to deal with that. You cannot just force every enumerator in a<br>
&gt; program to have runtime reflected data.<br>
<br>
Indeed.=C2=A0 Therefore, I think that using the template machinery for this=
<br>
would be a good thing.=C2=A0 If your program never instantiates<br>
`std::to_string&lt;MyEnum&gt;` (or whatever it is called), no string table =
of<br>
`MyEnum`s names has to be set aside.=C2=A0 And if you do instantiate it, yo=
u<br>
just pay for what you&#39;ve explicitly asked for.=C2=A0 While static analy=
sis<br>
could also be used to do this when implemented differently, compilers<br>
already do the right thing for templates so it wouldn&#39;t add extra<br>
complexity.<br>
<span class=3D"HOEnZb"><font color=3D"#888888"><br>
--<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%2Bunsubscribe@isocpp.org">std-propo=
sals+unsubscribe@<wbr>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/87vayosip3.fsf%40gmail.com" rel=3D"no=
referrer" target=3D"_blank">https://groups.google.com/a/<wbr>isocpp.org/d/m=
sgid/std-<wbr>proposals/87vayosip3.fsf%<wbr>40gmail.com</a>.<br>
</font></span></blockquote></div><br></div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CA%2BfGSbNGsK%3DYXhZfmU7%3DJPPGvdgpJ-=
MwTWThQwjxiACEMy9Tvg%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfoote=
r">https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CA%2BfGSbNG=
sK%3DYXhZfmU7%3DJPPGvdgpJ-MwTWThQwjxiACEMy9Tvg%40mail.gmail.com</a>.<br />

--001a11c0360a5502c1053afb7e23--

.
