220 2816 <511AA1A2.2080409@wanadoo.fr> article
Path: news.gmane.org!not-for-mail
From: "Vicente J. Botet Escriba" <vicente.botet@wanadoo.fr>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: minimal enum class improvements
Date: Tue, 12 Feb 2013 21:10:10 +0100
Lines: 552
Approved: news@gmane.org
Message-ID: <511AA1A2.2080409@wanadoo.fr>
References: <c15b7b1c-6d6f-4472-8a43-b2fb374b92a1@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative;
 boundary="------------010601020506020504060100"
X-Trace: ger.gmane.org 1360699819 26010 80.91.229.3 (12 Feb 2013 20:10:19 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Tue, 12 Feb 2013 20:10:19 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBDH67CONY4PBBJGD5KEAKGQE5DVRI2I@isocpp.org Tue Feb 12 21:10:41 2013
Return-path: <std-proposals+bncBDH67CONY4PBBJGD5KEAKGQE5DVRI2I@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-bk0-f70.google.com ([209.85.214.70])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBDH67CONY4PBBJGD5KEAKGQE5DVRI2I@isocpp.org>)
	id 1U5MBU-0000f5-9h
	for gclcip-std-proposals@m.gmane.org; Tue, 12 Feb 2013 21:10:32 +0100
Original-Received: by mail-bk0-f70.google.com with SMTP id jk7sf527205bkc.1
        for <gclcip-std-proposals@m.gmane.org>; Tue, 12 Feb 2013 12:10:13 -0800 (PST)
X-Received: by 10.180.14.162 with SMTP id q2mr894570wic.5.1360699812751;
        Tue, 12 Feb 2013 12:10:12 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.180.76.167 with SMTP id l7ls1204318wiw.52.canary; Tue, 12 Feb
 2013 12:10:12 -0800 (PST)
X-Received: by 10.194.108.229 with SMTP id hn5mr33689598wjb.8.1360699812204;
        Tue, 12 Feb 2013 12:10:12 -0800 (PST)
X-Received: by 10.194.108.229 with SMTP id hn5mr33689595wjb.8.1360699812179;
        Tue, 12 Feb 2013 12:10:12 -0800 (PST)
Original-Received: from smtp.smtpout.orange.fr (smtp03.smtpout.orange.fr. [80.12.242.125])
        by mx.google.com with ESMTP id ft6si5335675wib.55.2013.02.12.12.10.12;
        Tue, 12 Feb 2013 12:10:12 -0800 (PST)
Received-SPF: neutral (google.com: 80.12.242.125 is neither permitted nor denied by best guess record for domain of vicente.botet@wanadoo.fr) client-ip=80.12.242.125;
Original-Received: from iMac-de-Vicente-Botet-Escriba.local ([92.139.27.229])
	by mwinf5d38 with ME
	id zYAA1k00K4wbJms03YABm6; Tue, 12 Feb 2013 21:10:11 +0100
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:17.0) Gecko/20130107 Thunderbird/17.0.2
In-Reply-To: <c15b7b1c-6d6f-4472-8a43-b2fb374b92a1@isocpp.org>
X-Original-Sender: vicente.botet@wanadoo.fr
X-Original-Authentication-Results: mx.google.com;       spf=neutral
 (google.com: 80.12.242.125 is neither permitted nor denied by best guess
 record for domain of vicente.botet@wanadoo.fr) smtp.mail=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: <http://groups.google.com/a/isocpp.org/group/std-proposals/post?hl=en>,
 <mailto:std-proposals@isocpp.org>
List-Help: <http://support.google.com/a/isocpp.org/bin/topic.py?hl=en&topic=25838>,
 <mailto:std-proposals+help@isocpp.org>
List-Archive: <http://groups.google.com/a/isocpp.org/group/std-proposals/?hl=en>
List-Subscribe: <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe?hl=en>,
 <mailto:std-proposals+subscribe@isocpp.org>
List-Unsubscribe: <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe?hl=en>,
 <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:2816
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/2816>

This is a multi-part message in MIME format.
--------------010601020506020504060100
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: quoted-printable

Le 11/02/13 14:55, ricardofabianodeandrade@gmail.com a =E9crit :
> Hi all,
>
>
>
> *Request for change:*
>
> Inclusion of the following features in the C++ language support for enum:
>
>   * Obtain the number of enumerators of a given enum type.
>   * Obtain the value of an enumerator of a given enumerator's index
>     (or order, or position) and its enum type.
>

I would add to the minimal set of features this
|      * obtain |the position relative of an enumeration value in the=20
enum type.

This requires of course that all the enumerations have a distinct value.=20
The compiler could not provide these meta-functions if the enum doesn't=20
satisfy this condition.
In addition, the allowed values of an 'ordinal' enumeration type should=20
contain only the enumerations because otherwise the pos function could=20
not be defined. This is a breaking change or require adding a specific=20
syntax for 'ordinal' enumeration. Maybe using a new *ordinal* keyword=20
instead of enum could be an option

|*ordinal*classAnEnum:int{a =3D-1,b =3D1000,c =3D0};
|

> *Example *(please note no syntax is being suggested initially, just a=20
> [magic] placeholder):
> |
> enumclassAnEnum:int{a =3D-1,b =3D1000,c =3D0};
> std::size_t enumerators =3D[magic]<AnEnum>();
> AnEnumvalue =3D[magic]<AnEnum>(0);
> |
> *
> *
I find this syntax a little bit obscure. I would prefer specific=20
functions as size, val and pos.

     template <typename EC>
     constexpr std::size_t size() noexcept;
     template <typename EC>
     constexpr EC val(std::size_t) noexcept;
     template <typename EC>
     constexpr std::size_t pos(EC) noexcept;


|
enumclassAnEnum:int{a =3D-1,b =3D1000,c =3D0};
||||
constexpr ||||std::size_t enumerators =3Dsize<AnEnum>();|||

||||||||||
|||||
|||||||||||||
constexpr AnEnume2 =3Dval<AnEnum>(1);
| |||||||std::size_t n =3D 6;||||||||
||||||||||AnEnume2 =3Dval<AnEnum>(n); //runtime
|

||
|||||||||
|||||constexpr ||||std::size_t|indx =3D||pos(||||||||AnEnum::a||||||||);
| ||||||||||
|std::size_t|indx =3Dpos(e2); |||//runtime|||
|
*
*
|||
|

The pos runtime function could use the same algorithm the compiler uses=20
for a switch.
The constexpr pos function could be replaced directly at compile time.

first, last, succ and pred functions can be defined easily as follows

     template <typename EC>
     constexpr EC first() noexcept
     {
         return val<EC>(0);
     }
     template <typename EC>
     constexpr EC last() noexcept
     {
         return val<EC>(size<EC>()-1);
     }

     template <typename EC>
     constexpr EC succ(EC e)
     {
       //assert(pos(e)!=3D(size<EC>()-1));
       return val<EC>(pos(e)+1);
     }
     template <typename EC>
     constexpr EC pred(EC e)
     {
       //assert(pos(e)!=3D0);
       return val<EC>(pos(e)-1);
     }

Best,
Vicente

--=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/?hl=3Den.



--------------010601020506020504060100
Content-Type: text/html; charset=ISO-8859-1

<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">Le 11/02/13 14:55,
      <a class="moz-txt-link-abbreviated" href="mailto:ricardofabianodeandrade@gmail.com">ricardofabianodeandrade@gmail.com</a> a &eacute;crit&nbsp;:<br>
    </div>
    <blockquote
      cite="mid:c15b7b1c-6d6f-4472-8a43-b2fb374b92a1@isocpp.org"
      type="cite">Hi all,
      <div><br>
      </div>
      <br>
      <div><br>
      </div>
      <div><b>Request for change:</b><br>
      </div>
      <div><br>
      </div>
      <div>Inclusion of the following features in the C++ language
        support for <font face="courier new, monospace">enum</font>:</div>
      <div>
        <ul>
          <li>Obtain the number of enumerators of a given <font
              face="courier new, monospace">enum</font> type.</li>
          <li>Obtain the value of an enumerator&nbsp;of a given&nbsp;enumerator's
            index (or order, or position) and its&nbsp;<font face="courier
              new, monospace">enum</font> type.<br>
          </li>
        </ul>
      </div>
    </blockquote>
    <br>
    I would add to the minimal set of features this<br>
    <meta http-equiv="content-type" content="text/html;
      charset=ISO-8859-1">
    <code class="computeroutput"><span class="identifier">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; * obtain
      </span></code>the position relative of an enumeration value in the
    enum type. <br>
    <br>
    This requires of course that all the enumerations have a distinct
    value. The compiler could not provide these meta-functions if the
    enum doesn't satisfy this condition. <br>
    In addition, the allowed values of an 'ordinal' enumeration type
    should contain only the enumerations because otherwise the pos
    function could not be defined. This is a breaking change or require
    adding a specific syntax for 'ordinal' enumeration. Maybe using a
    new <b>ordinal</b> keyword instead of enum could be an option<br>
    <br>
    <code class="prettyprint"><b><span style="color: #008;"
          class="styled-by-prettify">ordinal</span></b><span
        style="color: #000;" class="styled-by-prettify"> </span><span
        style="color: #008;" class="styled-by-prettify">class</span><span
        style="color: #000;" class="styled-by-prettify"> </span><span
        style="color: #606;" class="styled-by-prettify">AnEnum</span><span
        style="color: #000;" class="styled-by-prettify"> </span><span
        style="color: #660;" class="styled-by-prettify">:</span><span
        style="color: #000;" class="styled-by-prettify"> </span><span
        style="color: #008;" class="styled-by-prettify">int</span><span
        style="color: #000;" class="styled-by-prettify"> </span><span
        style="color: #660;" class="styled-by-prettify">{</span><span
        style="color: #000;" class="styled-by-prettify"> a </span><span
        style="color: #660;" class="styled-by-prettify">=</span><span
        style="color: #000;" class="styled-by-prettify"> </span><span
        style="color: #660;" class="styled-by-prettify">-</span><span
        style="color: #066;" class="styled-by-prettify">1</span><span
        style="color: #660;" class="styled-by-prettify">,</span><span
        style="color: #000;" class="styled-by-prettify"> b </span><span
        style="color: #660;" class="styled-by-prettify">=</span><span
        style="color: #000;" class="styled-by-prettify"> </span><span
        style="color: #066;" class="styled-by-prettify">1000</span><span
        style="color: #660;" class="styled-by-prettify">,</span><span
        style="color: #000;" class="styled-by-prettify"> c </span><span
        style="color: #660;" class="styled-by-prettify">=</span><span
        style="color: #000;" class="styled-by-prettify"> </span><span
        style="color: #066;" class="styled-by-prettify">0</span><span
        style="color: #000;" class="styled-by-prettify"> </span><span
        style="color: #660;" class="styled-by-prettify">};</span><span
        style="color: #000;" class="styled-by-prettify"><br>
      </span></code><br>
    <br>
    <blockquote
      cite="mid:c15b7b1c-6d6f-4472-8a43-b2fb374b92a1@isocpp.org"
      type="cite">
      <div>
        <div><span style="line-height: 17px;"><b>Example </b>(please
            note no&nbsp;syntax&nbsp;is being suggested initially, just a <font
              face="courier new, monospace">[magic]</font> placeholder):</span></div>
      </div>
      <div style="background-color: rgb(250, 250, 250); border: 1px
        solid rgb(187, 187, 187); word-wrap: break-word;"
        class="prettyprint"><code class="prettyprint">
          <div class="subprettyprint"><span style="color: #008;"
              class="styled-by-prettify">enum</span><span style="color:
              #000;" class="styled-by-prettify"> </span><span
              style="color: #008;" class="styled-by-prettify">class</span><span
              style="color: #000;" class="styled-by-prettify"> </span><span
              style="color: #606;" class="styled-by-prettify">AnEnum</span><span
              style="color: #000;" class="styled-by-prettify"> </span><span
              style="color: #660;" class="styled-by-prettify">:</span><span
              style="color: #000;" class="styled-by-prettify"> </span><span
              style="color: #008;" class="styled-by-prettify">int</span><span
              style="color: #000;" class="styled-by-prettify"> </span><span
              style="color: #660;" class="styled-by-prettify">{</span><span
              style="color: #000;" class="styled-by-prettify"> a </span><span
              style="color: #660;" class="styled-by-prettify">=</span><span
              style="color: #000;" class="styled-by-prettify"> </span><span
              style="color: #660;" class="styled-by-prettify">-</span><span
              style="color: #066;" class="styled-by-prettify">1</span><span
              style="color: #660;" class="styled-by-prettify">,</span><span
              style="color: #000;" class="styled-by-prettify"> b </span><span
              style="color: #660;" class="styled-by-prettify">=</span><span
              style="color: #000;" class="styled-by-prettify"> </span><span
              style="color: #066;" class="styled-by-prettify">1000</span><span
              style="color: #660;" class="styled-by-prettify">,</span><span
              style="color: #000;" class="styled-by-prettify"> c </span><span
              style="color: #660;" class="styled-by-prettify">=</span><span
              style="color: #000;" class="styled-by-prettify"> </span><span
              style="color: #066;" class="styled-by-prettify">0</span><span
              style="color: #000;" class="styled-by-prettify"> </span><span
              style="color: #660;" class="styled-by-prettify">};</span><span
              style="color: #000;" class="styled-by-prettify"><br>
              std</span><span style="color: #660;"
              class="styled-by-prettify">::</span><span style="color:
              #000;" class="styled-by-prettify">size_t enumerators </span><span
              style="color: #660;" class="styled-by-prettify">=</span><span
              style="color: #000;" class="styled-by-prettify"> </span><span
              style="color: #660;" class="styled-by-prettify">[</span><span
              style="color: #000;" class="styled-by-prettify">magic</span><span
              style="color: #660;" class="styled-by-prettify">]&lt;</span><span
              style="color: #606;" class="styled-by-prettify">AnEnum</span><span
              style="color: #660;" class="styled-by-prettify">&gt;();</span><span
              style="color: #000;" class="styled-by-prettify"><br>
            </span><span style="color: #606;" class="styled-by-prettify">AnEnum</span><span
              style="color: #000;" class="styled-by-prettify"> value </span><span
              style="color: #660;" class="styled-by-prettify">=</span><span
              style="color: #000;" class="styled-by-prettify"> </span><span
              style="color: #660;" class="styled-by-prettify">[</span><span
              style="color: #000;" class="styled-by-prettify">magic</span><span
              style="color: #660;" class="styled-by-prettify">]&lt;</span><span
              style="color: #606;" class="styled-by-prettify">AnEnum</span><span
              style="color: #660;" class="styled-by-prettify">&gt;(</span><span
              style="color: #066;" class="styled-by-prettify">0</span><span
              style="color: #660;" class="styled-by-prettify">);</span></div>
        </code></div>
      <div>
        <div><span style="line-height: 17px;"><b><br>
            </b></span></div>
      </div>
    </blockquote>
    I find this syntax a little bit obscure. I would prefer specific
    functions as size, val and pos.<br>
    <br>
    &nbsp;&nbsp;&nbsp; template &lt;typename EC&gt;<br>
    &nbsp;&nbsp;&nbsp; constexpr std::size_t size() noexcept;<br>
    &nbsp;&nbsp;&nbsp; template &lt;typename EC&gt;<br>
    &nbsp;&nbsp;&nbsp; constexpr EC val(std::size_t) noexcept;<br>
    &nbsp;&nbsp;&nbsp; template &lt;typename EC&gt;<br>
    &nbsp;&nbsp;&nbsp; constexpr std::size_t pos(EC) noexcept;<br>
    <br>
    <br>
    <div style="background-color: rgb(250, 250, 250); border: 1px solid
      rgb(187, 187, 187); word-wrap: break-word;" class="prettyprint"><code
        class="prettyprint">
        <div class="subprettyprint"><span style="color: #008;"
            class="styled-by-prettify">enum</span><span style="color:
            #000;" class="styled-by-prettify"> </span><span
            style="color: #008;" class="styled-by-prettify">class</span><span
            style="color: #000;" class="styled-by-prettify"> </span><span
            style="color: #606;" class="styled-by-prettify">AnEnum</span><span
            style="color: #000;" class="styled-by-prettify"> </span><span
            style="color: #660;" class="styled-by-prettify">:</span><span
            style="color: #000;" class="styled-by-prettify"> </span><span
            style="color: #008;" class="styled-by-prettify">int</span><span
            style="color: #000;" class="styled-by-prettify"> </span><span
            style="color: #660;" class="styled-by-prettify">{</span><span
            style="color: #000;" class="styled-by-prettify"> a </span><span
            style="color: #660;" class="styled-by-prettify">=</span><span
            style="color: #000;" class="styled-by-prettify"> </span><span
            style="color: #660;" class="styled-by-prettify">-</span><span
            style="color: #066;" class="styled-by-prettify">1</span><span
            style="color: #660;" class="styled-by-prettify">,</span><span
            style="color: #000;" class="styled-by-prettify"> b </span><span
            style="color: #660;" class="styled-by-prettify">=</span><span
            style="color: #000;" class="styled-by-prettify"> </span><span
            style="color: #066;" class="styled-by-prettify">1000</span><span
            style="color: #660;" class="styled-by-prettify">,</span><span
            style="color: #000;" class="styled-by-prettify"> c </span><span
            style="color: #660;" class="styled-by-prettify">=</span><span
            style="color: #000;" class="styled-by-prettify"> </span><span
            style="color: #066;" class="styled-by-prettify">0</span><span
            style="color: #000;" class="styled-by-prettify"> </span><span
            style="color: #660;" class="styled-by-prettify">};</span><span
            style="color: #000;" class="styled-by-prettify"><br>
          </span><span style="color: #000;" class="styled-by-prettify"><code
              class="prettyprint"><code class="prettyprint"><code
                  class="prettyprint"><code class="prettyprint"><span
                      style="color: #606;" class="styled-by-prettify"><br>
                      constexpr </span></code></code></code></code>std</span><span
            style="color: #660;" class="styled-by-prettify">::</span><span
            style="color: #000;" class="styled-by-prettify">size_t
            enumerators </span><span style="color: #660;"
            class="styled-by-prettify">=</span><span style="color:
            #000;" class="styled-by-prettify"> </span><span
            style="color: #660;" class="styled-by-prettify">size</span><span
            style="color: #660;" class="styled-by-prettify">&lt;</span><span
            style="color: #606;" class="styled-by-prettify">AnEnum</span><span
            style="color: #660;" class="styled-by-prettify">&gt;();</span><span
            style="color: #000;" class="styled-by-prettify"></span><code
            class="prettyprint"><code class="prettyprint"><code
                class="prettyprint">
                <div class="subprettyprint"><br>
                  <span style="color: #606;" class="styled-by-prettify"><code
                      class="prettyprint"><span style="color: #000;"
                        class="styled-by-prettify"><code
                          class="prettyprint"><code class="prettyprint"><code
                              class="prettyprint"><code
                                class="prettyprint"><span style="color:
                                  #606;" class="styled-by-prettify"></span></code></code></code></code></span></code></span></div>
              </code></code></code><code class="prettyprint"><code
              class="prettyprint">
              <div class="subprettyprint"><span style="color: #606;"
                  class="styled-by-prettify"><code class="prettyprint"><code
                      class="prettyprint"><code class="prettyprint"><code
                          class="prettyprint"><span style="color: #606;"
                            class="styled-by-prettify"><code
                              class="prettyprint"><span style="color:
                                #000;" class="styled-by-prettify"><code
                                  class="prettyprint"><code
                                    class="prettyprint"><code
                                      class="prettyprint"><code
                                        class="prettyprint"><code
                                          class="prettyprint"><code
                                            class="prettyprint"><code
                                              class="prettyprint"><code
                                                class="prettyprint">
                                                <div
                                                  class="subprettyprint"><span
                                                    style="color: #606;"
class="styled-by-prettify">constexpr AnEnum</span><span style="color:
                                                    #000;"
                                                    class="styled-by-prettify">
                                                    e2 </span><span
                                                    style="color: #660;"
class="styled-by-prettify">=</span><span style="color: #000;"
                                                    class="styled-by-prettify">
                                                  </span><span
                                                    style="color: #660;"
class="styled-by-prettify">val</span><span style="color: #660;"
                                                    class="styled-by-prettify">&lt;</span><span
                                                    style="color: #606;"
class="styled-by-prettify">AnEnum</span><span style="color: #660;"
                                                    class="styled-by-prettify">&gt;(</span><span
                                                    style="color: #066;"
class="styled-by-prettify">1</span><span style="color: #660;"
                                                    class="styled-by-prettify">);<br>
                                                  </span></div>
                                              </code>
                                            </code></code></code></code></code></code></code>std</span><span
                                style="color: #660;"
                                class="styled-by-prettify">::</span><span
                                style="color: #000;"
                                class="styled-by-prettify">size_t n = 6;</span></code></span></code></code></code></code></span><code
                  class="prettyprint"><code class="prettyprint"><code
                      class="prettyprint">
                      <div class="subprettyprint"><span style="color:
                          #606;" class="styled-by-prettify"><code
                            class="prettyprint"><code
                              class="prettyprint"><code
                                class="prettyprint"><code
                                  class="prettyprint"><span
                                    style="color: #606;"
                                    class="styled-by-prettify"><code
                                      class="prettyprint"><span
                                        style="color: #000;"
                                        class="styled-by-prettify"></span></code></span></code></code></code></code>AnEnum</span><span
                          style="color: #000;"
                          class="styled-by-prettify"> e2 </span><span
                          style="color: #660;"
                          class="styled-by-prettify">=</span><span
                          style="color: #000;"
                          class="styled-by-prettify"> </span><span
                          style="color: #660;"
                          class="styled-by-prettify">val</span><span
                          style="color: #660;"
                          class="styled-by-prettify">&lt;</span><span
                          style="color: #606;"
                          class="styled-by-prettify">AnEnum</span><span
                          style="color: #660;"
                          class="styled-by-prettify">&gt;(</span><span
                          style="color: #066;"
                          class="styled-by-prettify">n</span><span
                          style="color: #660;"
                          class="styled-by-prettify">); //runtime<br>
                        </span></div>
                    </code>
                    <div><br>
                    </div>
                  </code></code></div>
            </code></code><code class="prettyprint"><code
              class="prettyprint"><code class="prettyprint"><code
                  class="prettyprint"><code class="prettyprint"><code
                      class="prettyprint"><code class="prettyprint">
                        <div class="subprettyprint"><code
                            class="prettyprint"><span style="color:
                              #000;" class="styled-by-prettify"><code
                                class="prettyprint"><code
                                  class="prettyprint"><code
                                    class="prettyprint"><code
                                      class="prettyprint"><span
                                        style="color: #606;"
                                        class="styled-by-prettify">constexpr
                                      </span></code></code></code></code>std</span><span
                              style="color: #660;"
                              class="styled-by-prettify">::</span><span
                              style="color: #000;"
                              class="styled-by-prettify">size_t</span></code><span
                            style="color: #000;"
                            class="styled-by-prettify"> indx </span><span
                            style="color: #660;"
                            class="styled-by-prettify">=</span><span
                            style="color: #000;"
                            class="styled-by-prettify"> </span><span
                            style="color: #000;"
                            class="styled-by-prettify"><code
                              class="prettyprint"><span style="color:
                                #000;" class="styled-by-prettify"></span></code>pos</span>(<code
                            class="prettyprint"><code
                              class="prettyprint"><code
                                class="prettyprint"><code
                                  class="prettyprint"><code
                                    class="prettyprint"><code
                                      class="prettyprint"><code
                                        class="prettyprint"><code
                                          class="prettyprint"><span
                                            style="color: #606;"
                                            class="styled-by-prettify">AnEnum</span><span
                                            style="color: #660;"
                                            class="styled-by-prettify">::a</span></code></code></code></code></code></code></code></code><span
                            style="color: #066;"
                            class="styled-by-prettify"></span><span
                            style="color: #660;"
                            class="styled-by-prettify">);</span></div>
                      </code>
                    </code></code></code></code></code></code><code
            class="prettyprint"><code class="prettyprint"><code
                class="prettyprint"><code class="prettyprint">
                  <div class="subprettyprint"><code class="prettyprint"><span
                        style="color: #000;" class="styled-by-prettify">std</span><span
                        style="color: #660;" class="styled-by-prettify">::</span><span
                        style="color: #000;" class="styled-by-prettify">size_t</span></code><span
                      style="color: #000;" class="styled-by-prettify">
                      indx </span><span style="color: #660;"
                      class="styled-by-prettify">=</span><span
                      style="color: #000;" class="styled-by-prettify"> </span><span
                      style="color: #000;" class="styled-by-prettify">pos</span><span
                      style="color: #660;" class="styled-by-prettify">(</span>e2<span
                      style="color: #066;" class="styled-by-prettify"></span><span
                      style="color: #660;" class="styled-by-prettify">);
                    </span><code class="prettyprint"><code
                        class="prettyprint"><code class="prettyprint"><span
                            style="color: #660;"
                            class="styled-by-prettify">//runtime</span></code></code></code></div>
                </code>
                <div>
                  <div><span style="line-height: 17px;"><b><br>
                      </b></span></div>
                </div>
              </code></code></code></div>
      </code></div>
    <br>
    The pos runtime function could use the same algorithm the compiler
    uses for a switch. <br>
    The constexpr pos function could be replaced directly at compile
    time.<br>
    <br>
    first, last, succ and pred functions can be defined easily as
    follows<br>
    <br>
    &nbsp;&nbsp;&nbsp; template &lt;typename EC&gt;<br>
    &nbsp;&nbsp;&nbsp; constexpr EC first() noexcept<br>
    &nbsp;&nbsp;&nbsp; {<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return val&lt;EC&gt;(0);<br>
    &nbsp;&nbsp;&nbsp; }<br>
    &nbsp;&nbsp;&nbsp; template &lt;typename EC&gt;<br>
    &nbsp;&nbsp;&nbsp; constexpr EC last() noexcept<br>
    &nbsp;&nbsp;&nbsp; {<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return val&lt;EC&gt;(size&lt;EC&gt;()-1);<br>
    &nbsp;&nbsp;&nbsp; }<br>
    <br>
    &nbsp;&nbsp;&nbsp; template &lt;typename EC&gt;<br>
    &nbsp;&nbsp;&nbsp; constexpr EC succ(EC e)<br>
    &nbsp;&nbsp;&nbsp; {<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //assert(pos(e)!=(size&lt;EC&gt;()-1));<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return val&lt;EC&gt;(pos(e)+1);<br>
    &nbsp;&nbsp;&nbsp; }<br>
    &nbsp;&nbsp;&nbsp; template &lt;typename EC&gt;<br>
    &nbsp;&nbsp;&nbsp; constexpr EC pred(EC e)<br>
    &nbsp;&nbsp;&nbsp; {<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //assert(pos(e)!=0);<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return val&lt;EC&gt;(pos(e)-1);<br>
    &nbsp;&nbsp;&nbsp; }<br>
    <br>
    Best,<br>
    Vicente<br>
  </body>
</html>

<p></p>

-- <br />
&nbsp;<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 email to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href="http://groups.google.com/a/isocpp.org/group/std-proposals/?hl=en">http://groups.google.com/a/isocpp.org/group/std-proposals/?hl=en</a>.<br />
&nbsp;<br />
&nbsp;<br />

--------------010601020506020504060100--

.
