220 27960 <c7969b41-3e76-c1d9-bd2f-b651be6e93f0@wanadoo.fr> article
Path: news.gmane.org!.POSTED!not-for-mail
From: "Vicente J. Botet Escriba" <vicente.botet@wanadoo.fr>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Re: Make (strongly typed) enums castable to char
 const * const
Date: Fri, 26 Aug 2016 13:10:19 +0200
Lines: 217
Approved: news@gmane.org
Message-ID: <c7969b41-3e76-c1d9-bd2f-b651be6e93f0@wanadoo.fr>
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>
 <CANh-dXmhWtTBeEwBheNOApVwiCkMB6Hwqg8n+xjt5aMvoW+pbg@mail.gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative;
 boundary="------------DD9DB034350D46A9669678A1"
X-Trace: blaine.gmane.org 1472209831 7475 195.159.176.226 (26 Aug 2016 11:10:31 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Fri, 26 Aug 2016 11:10:31 +0000 (UTC)
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:45.0)
 Gecko/20100101 Thunderbird/45.2.0
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBDH67CONY4PBBG6HQC7AKGQEZ2S6QCY@isocpp.org Fri Aug 26 13:10:23 2016
Return-path: <std-proposals+bncBDH67CONY4PBBG6HQC7AKGQEZ2S6QCY@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-wm0-f70.google.com ([74.125.82.70])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBDH67CONY4PBBG6HQC7AKGQEZ2S6QCY@isocpp.org>)
	id 1bdF1f-0000wU-GE
	for gclcip-std-proposals@m.gmane.org; Fri, 26 Aug 2016 13:10:19 +0200
Original-Received: by mail-wm0-f70.google.com with SMTP id u81sf52953426wmu.3
        for <gclcip-std-proposals@m.gmane.org>; Fri, 26 Aug 2016 04:10:20 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=subject:to:references:from:message-id:date:user-agent:mime-version
         :in-reply-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=aAJ/Z5ktfJjwMJK58fy+3LIT2WsZuDU01bEyGtzBMyo=;
        b=AsNhtqcH7GgURIi+DdJw90gfAw12JUlpunrcU37M26aoZI4hNviiCuKbB6BGPUUbKm
         nszNjvXxKd0EuE3ceXAGkibk/ezM+VE1q5bKPIAxVUsjPYd59AkZEbHUO91GsGUjMCT2
         clHcSkphyLaVNXoX9DARBFWlJSmMTnZGgIwzHzB8p5wZq8Vt2J/1OYMiLEv1MzcPvfTq
         o965mcPSejnZPY3t8W8Rogm9SAbobdN6ZnZCfvf+4cA2e5DV9/heMz5I8CtNdC0+19xL
         963xAWnmzseFL52vBMEzqsQmM8YRa/hHGctm5De8v2Ha0fxZEXE0fdWvaA1fNpX1jRDY
         FEhQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:subject:to:references:from:message-id:date
         :user-agent:mime-version:in-reply-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=aAJ/Z5ktfJjwMJK58fy+3LIT2WsZuDU01bEyGtzBMyo=;
        b=kzPQTSyyXF5+eqJcHnFhRDIQNGgocJ1JcrDsH8StyKn6kIgYKzwCR5LaA0IPLB9l28
         eVpRiJHTkaGDkUK7Y0lpHAQsYgPhJ+9wEHHOaU7/4ZBs+10hDAUFnU0+cKgVUXE38WBD
         3U/70sSjYSPP55isIu+xkTynOqVFfIqHe+retgljfxG0yLWdE9dTXnB0oBuPYw43luuK
         w2XgQvl9/SuOL5eCwojim8CML42DJHFobacrWoSIKTZaOqg5vNkwmbp9P/83DdZTzKlR
         0gz95SKEdf1X8V8x/2F4TjN7EPdiUZQnzYmZ20ijAtgbWz166z6Sjf6atkDHKj6TIubg
         x5EA==
X-Gm-Message-State: AE9vXwNTcTKGDdX/uQpDYemnsrC1zKsMTR3ua49UAHh06n5zoS7vw8AL1oX9o4gHRIuH/g==
X-Received: by 10.25.42.197 with SMTP id q188mr468658lfq.7.1472209820445;
        Fri, 26 Aug 2016 04:10:20 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.28.31.6 with SMTP id f6ls1005750wmf.11.gmail; Fri, 26 Aug 2016
 04:10:19 -0700 (PDT)
X-Received: by 10.28.96.11 with SMTP id u11mr3176340wmb.5.1472209819188;
        Fri, 26 Aug 2016 04:10:19 -0700 (PDT)
Original-Received: from smtp.smtpout.orange.fr (smtp02.smtpout.orange.fr. [80.12.242.124])
        by mx.google.com with ESMTPS id v207si36501545wmv.86.2016.08.26.04.10.19
        for <std-proposals@isocpp.org>
        (version=TLS1 cipher=AES128-SHA bits=128/128);
        Fri, 26 Aug 2016 04:10:19 -0700 (PDT)
Received-SPF: neutral (google.com: 80.12.242.124 is neither permitted nor denied by best guess record for domain of vicente.botet@wanadoo.fr) client-ip=80.12.242.124;
Original-Received: from pc38.home ([86.214.143.188])
	by mwinf5d49 with ME
	id bnAH1t00F4461ym03nAH28; Fri, 26 Aug 2016 13:10:18 +0200
X-ME-Helo: pc38.home
X-ME-Auth: dmljZW50ZS5ib3RldEB3YW5hZG9vLmZy
X-ME-Date: Fri, 26 Aug 2016 13:10:18 +0200
X-ME-IP: 86.214.143.188
In-Reply-To: <CANh-dXmhWtTBeEwBheNOApVwiCkMB6Hwqg8n+xjt5aMvoW+pbg@mail.gmail.com>
X-Original-Sender: vicente.botet@wanadoo.fr
X-Original-Authentication-Results: mx.google.com;       spf=neutral
 (google.com: 80.12.242.124 is neither permitted nor denied by best guess
 record for domain of vicente.botet@wanadoo.fr) smtp.mailfrom=vicente.botet@wanadoo.fr
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:27960
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/27960>

This is a multi-part message in MIME format.
--------------DD9DB034350D46A9669678A1
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: quoted-printable

Le 25/08/2016 =C3=A0 20:39, 'Jeffrey Yasskin' via ISO C++ Standard - Future=
=20
Proposals a =C3=A9crit :
> On Thu, Aug 25, 2016 at 11:10 AM, Dominic Fandrey=20
> <kamikaze@bsdforen.de <mailto: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 <mailto: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 =3D 2, DOSE =3D 2 };
>     > >
>     > > What will the result be for:
>     > >
>     > > FooBar fb =3D 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 =3D 0, COMPATIBLE =3D 1, COMPAT =3D 1,
>     EXPERIMENTAL =3D 2 };
>
> The static reflection proposal lets you iterate at compile time over=20
> all the enum values inside an enumeration, which lets you write a=20
> generic library function to do what you want. That function will have=20
> to pick an answer to FlagsString(1), and we're hoping that some=20
> libraries appear to show us some options before we put a choice into=20
> the standard library.
>

I'm working on a proposal for Ordinal types (types that are isomorphic=20
to 0..N. We could define an ordinal_set<Ordinal>, or an ordinal_array<T,=20
ordinal> or ordinal_range<Ordinal>.

Enums having all enumeration with a different value would be seen as=20
Ordinal. Associated to this enum could be a tag that defines the=20
algorithm to do the mappings. Possible mappings are arithmetic,=20
logarithmic or explicit. This tag can be calculated at compile time from=20
the static reflection library.

Defining a run-time function toString that takes such a ordinal enum=20
type and returns a const char * will be quite simple, once we are able=20
to have the position of a specific enumeration and the static reflection=20
library.

More soon.

Vicente


--=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.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/c7969b41-3e76-c1d9-bd2f-b651be6e93f0%40wanadoo.f=
r.

--------------DD9DB034350D46A9669678A1
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<html>
  <head>
    <meta content=3D"text/html; charset=3Dwindows-1252"
      http-equiv=3D"Content-Type">
  </head>
  <body bgcolor=3D"#FFFFFF" text=3D"#000000">
    <div class=3D"moz-cite-prefix">Le 25/08/2016 =C3=A0 20:39, 'Jeffrey
      Yasskin' via ISO C++ Standard - Future Proposals a =C3=A9crit=C2=A0:<=
br>
    </div>
    <blockquote
cite=3D"mid:CANh-dXmhWtTBeEwBheNOApVwiCkMB6Hwqg8n+xjt5aMvoW+pbg@mail.gmail.=
com"
      type=3D"cite">
      <div dir=3D"ltr">
        <div class=3D"gmail_extra">
          <div class=3D"gmail_quote">On Thu, Aug 25, 2016 at 11:10 AM,
            Dominic Fandrey <span dir=3D"ltr">&lt;<a
                moz-do-not-send=3D"true"
                href=3D"mailto:kamikaze@bsdforen.de" target=3D"_blank"
                class=3D"cremed">kamikaze@bsdforen.de</a>&gt;</span>
            wrote:<br>
            <blockquote class=3D"gmail_quote" style=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
                  moz-do-not-send=3D"true"
                  href=3D"mailto:antiquarktv@gmail.com" class=3D"cremed">an=
tiquarktv@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 "throws a wrench into the reflection
                works" as proposed by the<br>
                &gt; OP, by no means generally. the WG proposal linked
                (A) would not support<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's not really useful for what I'm doing if it's not
              runtime capable.<br>
              <br>
              For multiple mentions I'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 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.</div>
            <div><br>
            </div>
          </div>
        </div>
      </div>
    </blockquote>
    <br>
    I'm working on a proposal for Ordinal types (types that are
    isomorphic to 0..N. We could define an ordinal_set&lt;Ordinal&gt;,
    or an ordinal_array&lt;T, ordinal&gt; or
    ordinal_range&lt;Ordinal&gt;.<br>
    <br>
    Enums having all enumeration with a different value would be seen as
    Ordinal. Associated to this enum could be a tag that defines the
    algorithm to do the mappings. Possible mappings are arithmetic,
    logarithmic or explicit. This tag can be calculated at compile time
    from the static reflection library.<br>
    <br>
    Defining a run-time function toString that takes such a ordinal enum
    type and returns a const char * will be quite simple, once we are
    able to have the position of a specific enumeration and the static
    reflection library.<br>
    <br>
    More soon.<br>
    <br>
    Vicente<br>
    <br>
    <br>
  </body>
</html>

<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/c7969b41-3e76-c1d9-bd2f-b651be6e93f0%=
40wanadoo.fr?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/c7969b41-3e76-c1d9-bd2f-b651be6e93f0=
%40wanadoo.fr</a>.<br />

--------------DD9DB034350D46A9669678A1--

.
