220 27949 <CANh-dXmhWtTBeEwBheNOApVwiCkMB6Hwqg8n+xjt5aMvoW+pbg@mail.gmail.com> article
Path: news.gmane.org!.POSTED!not-for-mail
From: "'Jeffrey Yasskin' via ISO C++ Standard - Future Proposals" <std-proposals@isocpp.org>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Re: Make (strongly typed) enums castable to char
 const * const
Date: Thu, 25 Aug 2016 11:39:36 -0700
Lines: 126
Approved: news@gmane.org
Message-ID: <CANh-dXmhWtTBeEwBheNOApVwiCkMB6Hwqg8n+xjt5aMvoW+pbg@mail.gmail.com>
References: <1472132849.17129.9.camel@bsdforen.de> <e585a9d9-c120-48a9-9ab7-2cbfbc206038@isocpp.org>
 <CACGiwhG3EF5_+Ytu9k3h8gtYdmLCkkA0e109u2RfmPtForNMcA@mail.gmail.com> <1472148645.17129.15.camel@bsdforen.de>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary=001a113fe54075d944053ae9b97a
X-Trace: blaine.gmane.org 1472150404 30804 195.159.176.226 (25 Aug 2016 18:40:04 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Thu, 25 Aug 2016 18:40:04 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBDDM34EO6QDRB7PW7S6QKGQEZ4EUVLQ@isocpp.org Thu Aug 25 20:40:00 2016
Return-path: <std-proposals+bncBDDM34EO6QDRB7PW7S6QKGQEZ4EUVLQ@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-ua0-f198.google.com ([209.85.217.198])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBDDM34EO6QDRB7PW7S6QKGQEZ4EUVLQ@isocpp.org>)
	id 1bczZH-0007Rt-7m
	for gclcip-std-proposals@m.gmane.org; Thu, 25 Aug 2016 20:39:59 +0200
Original-Received: by mail-ua0-f198.google.com with SMTP id r91sf105766611uar.0
        for <gclcip-std-proposals@m.gmane.org>; Thu, 25 Aug 2016 11:40:00 -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=TRGalCCkw16DLKtTjl9PuFOh3NNIkIHU5uTl52DwR3A=;
        b=R484PQkVXx4TKquKckPZvWbsXqx1Iac5lPcdfLItwiHaBqyvmDWNuoadQOi4YcTBl9
         MXuyAIP252tO9GFNy0SvOKUnDh715SYt0HW+Tok3Z/lhPOPIihKUSgWqqkHQ/zUgf2hl
         h/3nssnxkFAYLauMi8F/3+uO9zM9h6uncX6+j9kY8kYsHymbIbwtWej+mIFPLBGJxYem
         LdwuXlM5zOW7MWU0RvekLx19DNLWwT7jpa7Gc8HtO5v7OPb0s/EkVlXrBFqSIggprsH7
         g/u6O+dTM26Pggr/Wxo4+3qJMnllQ8QJ5hSDKJhGXIRGMMjuJ0uw2bNDWRAbXjZVStXn
         1A9g==
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=TRGalCCkw16DLKtTjl9PuFOh3NNIkIHU5uTl52DwR3A=;
        b=Pcwpp0+5Hm6CqFStHx7LnOJCAMppLMfM/R4o9RTwyo0Y+i8c2y850xkm6PbnJU9SOH
         2i+vCkKOGcFcGVaNDPxUDhNaRbz7x2ZAesd63IGgShHeIWCHUifh/YcBbF4pl27NJBnj
         RblFbnlDSeiD08nfFkFsLWnfJOp9YvUjq9K6aJlQtHy+knA1bCDOGqgs1MNeTCqaNFxh
         eBW2GlNpjJRvOIX3UiA2q4rhs25ZOKjyc6iTtHxmEuJBYKSEf6dK4lqAXxg5pz3AqaFm
         f0mdrj8lwYauUGWRWqyS1i14C6HxdGXLnflYSfX2bde9jxdBarwN9ktgMFuq016aGkip
         PVtg==
X-Gm-Message-State: AE9vXwN8RU2oCENVbgTUMLRoLREMuxX6bACWcjGCE5GEBtRKqSUSn9ONfoQA4YD3h3oIWA==
X-Received: by 10.129.155.142 with SMTP id s136mr6771611ywg.22.1472150398863;
        Thu, 25 Aug 2016 11:39:58 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.107.169.101 with SMTP id s98ls668535ioe.53.gmail; Thu, 25 Aug
 2016 11:39:57 -0700 (PDT)
X-Received: by 10.107.160.202 with SMTP id j193mr12039217ioe.23.1472150397601;
        Thu, 25 Aug 2016 11:39:57 -0700 (PDT)
Original-Received: from mail-it0-x22a.google.com (mail-it0-x22a.google.com. [2607:f8b0:4001:c0b::22a])
        by mx.google.com with ESMTPS id k21si19663185iok.96.2016.08.25.11.39.57
        for <std-proposals@isocpp.org>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Thu, 25 Aug 2016 11:39:57 -0700 (PDT)
Received-SPF: pass (google.com: domain of jyasskin@google.com designates 2607:f8b0:4001:c0b::22a as permitted sender) client-ip=2607:f8b0:4001:c0b::22a;
Original-Received: by mail-it0-x22a.google.com with SMTP id e63so34813125ith.1
        for <std-proposals@isocpp.org>; Thu, 25 Aug 2016 11:39:57 -0700 (PDT)
X-Received: by 10.107.13.204 with SMTP id 195mr8829271ion.89.1472150396826;
 Thu, 25 Aug 2016 11:39:56 -0700 (PDT)
Original-Received: by 10.64.19.205 with HTTP; Thu, 25 Aug 2016 11:39:36 -0700 (PDT)
In-Reply-To: <1472148645.17129.15.camel@bsdforen.de>
X-Original-Sender: jyasskin@google.com
X-Original-Authentication-Results: mx.google.com;       dkim=pass
 header.i=@google.com;       spf=pass (google.com: domain of
 jyasskin@google.com designates 2607:f8b0:4001:c0b::22a as permitted sender)
 smtp.mailfrom=jyasskin@google.com;       dmarc=pass (p=REJECT dis=NONE) header.from=google.com
X-Original-From: Jeffrey Yasskin <jyasskin@google.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:27949
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/27949>

--001a113fe54075d944053ae9b97a
Content-Type: text/plain; charset=UTF-8

On Thu, Aug 25, 2016 at 11:10 AM, Dominic Fandrey <kamikaze@bsdforen.de>
wrote:

> On Thu, 2016-08-25 at 16:55 +0100, D. B. wrote:
> > On Thu, Aug 25, 2016 at 4:17 PM, Derek Ross <antiquarktv@gmail.com>
> wrote:
> >
> > >
> > > Note that enums can have duplicate values, which throws a wrench into
> the
> > > reflection works.  E.g.:
> > >
> > > enum class FooBar { KEKS = 2, DOSE = 2 };
> > >
> > > What will the result be for:
> > >
> > > FooBar fb = FooBar::KEKS;
> > > cout << static_cast<char const*>(fb) ;
> > >
> > that only "throws a wrench into the reflection works" as proposed by the
> > OP, by no means generally. the WG proposal linked (A) would not support
> > this because it is static and (B) has presumably already accounted for
> such
> > possibilities and effortlessly gets around them with compile-time
> > wizardry... again, *presumably.*
> >
>
> It's not really useful for what I'm doing if it's not runtime capable.
>
> For multiple mentions I'd just leave it implementation defined or
> establish a simple first definition rule.
>
> I am assuming that in most cases overlapping definitions are aliases:
>
>     enum class Flags { NONE = 0, COMPATIBLE = 1, COMPAT = 1, EXPERIMENTAL
> = 2 };
>

The static reflection proposal lets you iterate at compile time over all
the enum values inside an enumeration, which lets you write a generic
library function to do what you want. That function will have to pick an
answer to FlagsString(1), and we're hoping that some libraries appear to
show us some options before we put a choice into the standard library.

Jeffrey

-- 
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/CANh-dXmhWtTBeEwBheNOApVwiCkMB6Hwqg8n%2Bxjt5aMvoW%2Bpbg%40mail.gmail.com.

--001a113fe54075d944053ae9b97a
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote">On T=
hu, Aug 25, 2016 at 11:10 AM, Dominic Fandrey <span dir=3D"ltr">&lt;<a href=
=3D"mailto:kamikaze@bsdforen.de" target=3D"_blank" class=3D"cremed">kamikaz=
e@bsdforen.de</a>&gt;</span> wrote:<br><blockquote class=3D"gmail_quote" st=
yle=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span=
 class=3D"">On Thu, 2016-08-25 at 16:55 +0100, D. B. wrote:<br>
&gt; On Thu, Aug 25, 2016 at 4:17 PM, Derek Ross &lt;<a href=3D"mailto:anti=
quarktv@gmail.com" class=3D"cremed">antiquarktv@gmail.com</a>&gt; wrote:<br=
>
&gt;<br>
&gt; &gt;<br>
&gt; &gt; Note that enums can have duplicate values, which throws a wrench =
into the<br>
&gt; &gt; reflection works.=C2=A0=C2=A0E.g.:<br>
&gt; &gt;<br>
&gt; &gt; enum class FooBar { KEKS =3D 2, DOSE =3D 2 };<br>
&gt; &gt;<br>
&gt; &gt; What will the result be for:<br>
&gt; &gt;<br>
&gt; &gt; FooBar fb =3D FooBar::KEKS;<br>
&gt; &gt; cout &lt;&lt; static_cast&lt;char const*&gt;(fb) ;<br>
&gt; &gt;<br>
&gt; that only &quot;throws a wrench into the reflection works&quot; as pro=
posed by the<br>
&gt; OP, by no means generally. the WG proposal linked (A) would not suppor=
t<br>
&gt; this because it is static and (B) has presumably already accounted for=
 such<br>
&gt; possibilities and effortlessly gets around them with compile-time<br>
</span>&gt; wizardry... again, *presumably.*<br>
&gt;<br>
<br>
It&#39;s not really useful for what I&#39;m doing if it&#39;s not runtime c=
apable.<br>
<br>
For multiple mentions I&#39;d just leave it implementation defined or<br>
establish a simple first definition rule.<br>
<br>
I am assuming that in most cases overlapping definitions are aliases:<br>
<br>
=C2=A0 =C2=A0 enum class Flags { NONE =3D 0, COMPATIBLE =3D 1, COMPAT =3D 1=
, EXPERIMENTAL =3D 2 };<span class=3D""><br></span></blockquote><div>=C2=A0=
</div><div>The static reflection proposal lets you iterate at compile time =
over all the enum values inside an enumeration, which lets you write a gene=
ric library function to do what you want. That function will have to pick a=
n answer to FlagsString(1), and we&#39;re hoping that some libraries appear=
 to show us some options before we put a choice into the standard library.<=
/div><div><br></div><div>Jeffrey</div></div></div></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/CANh-dXmhWtTBeEwBheNOApVwiCkMB6Hwqg8n=
%2Bxjt5aMvoW%2Bpbg%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter"=
>https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CANh-dXmhWtTB=
eEwBheNOApVwiCkMB6Hwqg8n%2Bxjt5aMvoW%2Bpbg%40mail.gmail.com</a>.<br />

--001a113fe54075d944053ae9b97a--

.
