220 30471 <040e99e3-8f07-409f-3a47-ebdfb2bfb465@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: enum_cast proposal
Date: Tue, 10 Jan 2017 23:26:08 +0100
Lines: 526
Approved: news@gmane.org
Message-ID: <040e99e3-8f07-409f-3a47-ebdfb2bfb465@wanadoo.fr>
References: <efdf2357-00a6-408a-8772-12f99135a880@isocpp.org>
 <57258435-5d82-48e7-8ed7-3c38682418fb@isocpp.org>
 <a35d9f20-9e4f-4789-b7e5-5cb08f99e6bd@isocpp.org>
 <e779f1ca-8f05-7eda-72c8-89a9a5215c62@wanadoo.fr>
 <24e58aad-ecbc-4c83-a21b-de56ea4c1db0@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative;
 boundary="------------BF1F89400088942B4377F680"
X-Trace: blaine.gmane.org 1484087185 29451 195.159.176.226 (10 Jan 2017 22:26:25 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Tue, 10 Jan 2017 22:26:25 +0000 (UTC)
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:45.0)
 Gecko/20100101 Thunderbird/45.6.0
Cc: m.cencora@gmail.com, gmisocpp@gmail.com
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBDH67CONY4PBBAV72XBQKGQE3JP4DOQ@isocpp.org Tue Jan 10 23:26:20 2017
Return-path: <std-proposals+bncBDH67CONY4PBBAV72XBQKGQE3JP4DOQ@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-lf0-f70.google.com ([209.85.215.70])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBDH67CONY4PBBAV72XBQKGQE3JP4DOQ@isocpp.org>)
	id 1cR4rm-0005jE-Uq
	for gclcip-std-proposals@m.gmane.org; Tue, 10 Jan 2017 23:26:07 +0100
Original-Received: by mail-lf0-f70.google.com with SMTP id h65sf29583024lfi.1
        for <gclcip-std-proposals@m.gmane.org>; Tue, 10 Jan 2017 14:26:11 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=subject:to:references:cc: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=LERhjjdrlTR7hxRKHZZcTUCNlNkxawgjMhUlUDh5icE=;
        b=1sj15AbFI8hL4JLaHd+wliyXaXVCaLadtuDHT1dE8rcqAcAQ54moXWYbrCCBQQe6kX
         VbFPOI7t+64oHcvoRUaRv8Ob0t9+nz7E+D6/mZWNw6JkJjc4c0fWsR+yuZwMFOF8dZUg
         jRY5eHWpTpPvfMH+s4bIb4Uk23YFTKpK7SjPK1E6TrtSiXg4TQJeZGVF4KfxDvixwPKE
         syEmERJwXrMpYe53N8ReO9m0s+dQVR5m6kdoKy4BAELYj5nBLZZtC5swWWiGS6IFY4bP
         WzSUKMfFXQik2B+iI5/CcNcwUL1+kpTzEb9nNt3x+KIt6xd1zjZd/VXUyxxdrwI2hnrl
         dwUg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:subject:to:references:cc: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=LERhjjdrlTR7hxRKHZZcTUCNlNkxawgjMhUlUDh5icE=;
        b=P7JhrQ8EyhN3wOtTKAvtXX8dnEO94A417ZcVDyuYffyAEOR6s6PHF6Mk0xSEMKyDiV
         UbvWCnN7BN9/aYxl+NMqDJy9NWy2Af85W7o4DKVMh3tCr3cCeoNWIoxcFxBElYaMt2K0
         1F4IyyxMHhSVtQqhl0h9YEI7JxL8Zy8gTVNUh6RIbQFCabtBDJFwqDt4uqYYZ5V0xviY
         YWdyDxchYYJ2QuHfcDiBaOPR4C2Q8s2UcEzEvgVrLCYDg78U5YQT9REW4/j3VSrL3fN8
         +FbLa6J4njnOR+mJsXtgAZZzwTieSqvZvMkuRAgnEP6iss1rieLFJNVWiNJVofpb6FGe
         pScQ==
X-Gm-Message-State: AIkVDXIYG2ofKj9ZPnAZTw6yY00lfhGJRS86L73H+A8A/NF2lc5Z21JUx8oDtPTIcL40yA==
X-Received: by 10.46.83.78 with SMTP id t14mr502671ljd.26.1484087171389;
        Tue, 10 Jan 2017 14:26:11 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.28.69.202 with SMTP id l71ls476533wmi.27.gmail; Tue, 10 Jan
 2017 14:26:10 -0800 (PST)
X-Received: by 10.194.77.83 with SMTP id q19mr2957304wjw.186.1484087169997;
        Tue, 10 Jan 2017 14:26:09 -0800 (PST)
Original-Received: from smtp.smtpout.orange.fr (smtp04.smtpout.orange.fr. [80.12.242.126])
        by mx.google.com with ESMTPS id z80si3087462wmd.57.2017.01.10.14.26.09
        for <std-proposals@isocpp.org>
        (version=TLS1 cipher=AES128-SHA bits=128/128);
        Tue, 10 Jan 2017 14:26:09 -0800 (PST)
Received-SPF: neutral (google.com: 80.12.242.126 is neither permitted nor denied by best guess record for domain of vicente.botet@wanadoo.fr) client-ip=80.12.242.126;
Original-Received: from imac-de-vicente-botet-escriba.home ([2.11.64.156])
	by mwinf5d59 with ME
	id WmS81u00c3NGJZe03mS83g; Tue, 10 Jan 2017 23:26:09 +0100
X-ME-Helo: imac-de-vicente-botet-escriba.home
X-ME-Auth: dmljZW50ZS5ib3RldEB3YW5hZG9vLmZy
X-ME-Date: Tue, 10 Jan 2017 23:26:09 +0100
X-ME-IP: 2.11.64.156
In-Reply-To: <24e58aad-ecbc-4c83-a21b-de56ea4c1db0@isocpp.org>
X-Original-Sender: vicente.botet@wanadoo.fr
X-Original-Authentication-Results: mx.google.com;       spf=neutral
 (google.com: 80.12.242.126 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:30471
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/30471>

This is a multi-part message in MIME format.
--------------BF1F89400088942B4377F680
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: quoted-printable

Le 10/01/2017 =C3=A0 20:30, Nicol Bolas a =C3=A9crit :
>
>
> On Tuesday, January 10, 2017 at 1:49:05 PM UTC-5, Vicente J. Botet=20
> Escriba wrote:
>
>     Le 10/01/2017 =C3=A0 16:31, m.ce...@gmail.com <javascript:> a =C3=A9c=
rit :
>>
>>     W dniu wtorek, 10 stycznia 2017 13:49:00 UTC+1 u=C5=BCytkownik
>>     gmis...@gmail.com napisa=C5=82:
>>
>>
>>
>>         On Tuesday, January 3, 2017 at 10:56:05 PM UTC+13,
>>         m.ce...@gmail.com wrote:
>>
>>             Hi,
>>
>>
>>     I'll try to create a first draft after I get some more comments
>>     w.r.t to exceptions.
>>     For sure baseline API must be exception-free.
>>     Do we really want to additionally support API that throws on error?
>>     I'm rather inclined to leave it out - similarly as in
>>     to_chars/from_chars.
>>
>>
>>         I hope this post assists you with your proposal. My
>>         suggestions are for your proposal to look something like this:
>>
>>         In <utility> I think add:
>>
>>         bool template<typename E, typename V> is_enum( V ev )
>>         {
>>          // compiler magic:
>>          // Calling this routine causes the compiler to generate or a
>>         call a routine
>>          // that returns true if the value ev matches one of the enum E'=
s
>>          // values. otherwise false.
>>         }
>>
>>
>>     'is_enum' name is already used in type_traits header.
>>     Also is_enum seems redundant to me, since to_enum already reports
>>     if convertion succeeded instead of:
>>     |
>>     if(is_enum<MyEnum>(139))
>>     |
>>
>>     you could write:
>>     |
>>     if(to_enum<MyEnum>(139).is_valid)
>>     |
>>
>>     or even:
>>     |
>>     if(to_enum<MyEnum>(139))
>>     |
>>     if we add explicit bool convertion operator for to_enum_result.
>>
>>
>     I believe we need two checking functions:
>     * is_enumerator : checks if the explicit conversion from the
>     integer is one of the explicit enumerators
>     * is_in_enum_range: checks if the integer is in the range of valid
>     values. This is the precondition of the static_cast.
>
>     IIUC when the underlying type is explicit, the range of values are
>     the range of the underlying type. However when the underlying type
>     is implicit the range goes from the min to the max of the values
>     of the enumerators.
>
>
> Right, but `is_enumerator` is a functional superset of=20
> `is_in_enum_range`. Do people really need to ask /only/ if a value is=20
> in the range of an enumerator?
I don't follow you. You surely wanted to say subset

The standard says in 7.2/8 :

     6.

        8 For an enumeration whose underlying type is fixed, the values
        of the enumeration are the values of the underlying type.
        Otherwise, for an enumeration where emin is the smallest
        enumerator and emax is the largest, the values of the
        enumeration are the values in the range bmin to bmax, defined as
        follows: Let K be 1 for a two=E2=80=99s complement representation a=
nd 0
        for a ones=E2=80=99 complement or sign-magnitude representation. bm=
ax is
        the smallest value greater than or equal to max(|emin| =E2=88=92 K,
        |emax|) and equal to 2M =E2=88=92 1, where M is a non-negative inte=
ger.
        bmin is zero if emin is non-negative and =E2=88=92(bmax + K) otherw=
ise.
        The size of the smallest bit-field large enough to hold all the
        values of the enumeration type is max(M,1) if bmin is zero and M
        + 1 otherwise. *It is possible to define an enumeration that has
        values not defined by any of its enumerators.* If the
        enumerator-list is empty, the values of the enumeration are as
        if the enumeration had a single enumerator with value 0.

    C++ International Standa

For me enumerators are any one of the named enum values. This set is a=20
subset  not a superset of the range of valid values.

As I said, until we don't have enums that consists only of the=20
enumerators, there would be always the need to check if a value is a=20
valid value for the enumeration.

We could define a class that accepts only the enumerators as valid=20
values, but the language enums can accept more values.
This is way I believe that the two checks are needed.

I don't know why the new C++11 enum with an explicit underlying type=20
have a different range of valid values.
I'll be interested in knowing the rationale.

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/040e99e3-8f07-409f-3a47-ebdfb2bfb465%40wanadoo.f=
r.

--------------BF1F89400088942B4377F680
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<html>
  <head>
    <meta content=3D"text/html; charset=3Dutf-8" http-equiv=3D"Content-Type=
">
  </head>
  <body bgcolor=3D"#FFFFFF" text=3D"#000000">
    <div class=3D"moz-cite-prefix">Le 10/01/2017 =C3=A0 20:30, Nicol Bolas =
a
      =C3=A9crit=C2=A0:<br>
    </div>
    <blockquote
      cite=3D"mid:24e58aad-ecbc-4c83-a21b-de56ea4c1db0@isocpp.org"
      type=3D"cite">
      <div dir=3D"ltr"><br>
        <br>
        On Tuesday, January 10, 2017 at 1:49:05 PM UTC-5, Vicente J.
        Botet Escriba wrote:
        <blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left:
          0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">
          <div bgcolor=3D"#FFFFFF" text=3D"#000000">
            <div>Le 10/01/2017 =C3=A0 16:31, <a moz-do-not-send=3D"true"
                href=3D"javascript:" target=3D"_blank"
                gdf-obfuscated-mailto=3D"H06U3IL9BQAJ" rel=3D"nofollow"
                onmousedown=3D"this.href=3D'javascript:';return true;"
                onclick=3D"this.href=3D'javascript:';return true;">m.ce...@=
gmail.com</a>
              a =C3=A9crit=C2=A0:<br>
            </div>
            <blockquote type=3D"cite">
              <div dir=3D"ltr"><br>
                W dniu wtorek, 10 stycznia 2017 13:49:00 UTC+1
                u=C5=BCytkownik <a moz-do-not-send=3D"true">gmis...@gmail.c=
om</a>
                napisa=C5=82:
                <blockquote class=3D"gmail_quote"
                  style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc
                  solid;padding-left:1ex">
                  <div dir=3D"ltr"><br>
                    <br>
                    On Tuesday, January 3, 2017 at 10:56:05 PM UTC+13, <a
                      moz-do-not-send=3D"true">m.ce...@gmail.com</a>
                    wrote:
                    <blockquote class=3D"gmail_quote" style=3D"margin:0px
                      0px 0px
0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width=
:1px;border-left-style:solid">
                      <div dir=3D"ltr">Hi,
                        <div><br>
                        </div>
                      </div>
                    </blockquote>
                  </div>
                </blockquote>
                <br>
                <div>I'll try to create a first draft after I get some
                  more comments w.r.t to exceptions.</div>
                <div>For sure baseline API must be exception-free.</div>
                <div>Do we really want to additionally support API that
                  throws on error?</div>
                <div>I'm rather inclined to leave it out - similarly as
                  in to_chars/from_chars.</div>
                <div>=C2=A0</div>
                <blockquote class=3D"gmail_quote"
                  style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc
                  solid;padding-left:1ex">
                  <div dir=3D"ltr">
                    <div><br>
                    </div>
                    <div>I hope this post assists you with your
                      proposal.=C2=A0My suggestions are for your proposal t=
o
                      look something like this:</div>
                    <div><br>
                    </div>
                    <div>In &lt;utility&gt; I think add:</div>
                    <div><br>
                    </div>
                    <div>bool template&lt;typename E, typename V&gt;
                      is_enum( V ev )</div>
                    <div>{</div>
                    <div>=C2=A0// compiler=C2=A0magic:</div>
                    <div>=C2=A0// Calling this routine causes the compiler =
to
                      generate or a call a routine</div>
                    <div>=C2=A0// that returns true if the value ev matches
                      one of the enum E's</div>
                    <div>=C2=A0// values. otherwise false.</div>
                    <div>}</div>
                  </div>
                </blockquote>
                <div><br>
                </div>
                <div>'is_enum' name is already used in type_traits
                  header.<br>
                </div>
                <div>Also is_enum seems redundant to me, since to_enum
                  already reports</div>
                <div>if convertion succeeded instead of:</div>
                <div>
                  <div style=3D"border:1px solid
                    rgb(187,187,187);word-wrap:break-word;background-color:=
rgb(250,250,250)"><code>
                      <div><span style=3D"color:#008">if</span><span
                          style=3D"color:#000"> </span><span
                          style=3D"color:#660">(</span><span
                          style=3D"color:#000">is_enum</span><span
                          style=3D"color:#660">&lt;</span><span
                          style=3D"color:#606">MyEnum</span><span
                          style=3D"color:#660">&gt;(</span><span
                          style=3D"color:#066">139</span><span
                          style=3D"color:#660">))</span></div>
                    </code></div>
                  <br>
                </div>
                <div>you could write:</div>
                <div>
                  <div style=3D"border:1px solid
                    rgb(187,187,187);word-wrap:break-word;background-color:=
rgb(250,250,250)"><code>
                      <div><span style=3D"color:#008">if</span><span
                          style=3D"color:#000"> </span><span
                          style=3D"color:#660">(</span><span
                          style=3D"color:#000">to_enum</span><span
                          style=3D"color:#660">&lt;</span><span
                          style=3D"color:#606">MyEnum</span><span
                          style=3D"color:#660">&gt;(</span><span
                          style=3D"color:#066">139</span><span
                          style=3D"color:#660">).</span><span
                          style=3D"color:#000">is_valid</span><span
                          style=3D"color:#660"><wbr>)</span></div>
                    </code></div>
                  <br>
                </div>
                <div>or even:</div>
                <div>
                  <div style=3D"border:1px solid
                    rgb(187,187,187);word-wrap:break-word;background-color:=
rgb(250,250,250)"><code>
                      <div><span style=3D"color:#008">if</span><span
                          style=3D"color:#000"> </span><span
                          style=3D"color:#660">(</span><span
                          style=3D"color:#000">to_enum</span><span
                          style=3D"color:#660">&lt;</span><span
                          style=3D"color:#606">MyEnum</span><span
                          style=3D"color:#660">&gt;(</span><span
                          style=3D"color:#066">139</span><span
                          style=3D"color:#660">))</span></div>
                    </code></div>
                  if we add explicit bool convertion operator for
                  to_enum_result.</div>
                <div><br>
                </div>
                <div><br>
                </div>
              </div>
            </blockquote>
            I believe we need two checking functions:<br>
            * is_enumerator : checks if the explicit conversion from the
            integer is one of the explicit enumerators<br>
            * is_in_enum_range: checks if the integer is in the range of
            valid values. This is the precondition of the static_cast.<br>
            <br>
            IIUC when the underlying type is explicit, the range of
            values are the range of the underlying type. However when
            the underlying type is implicit the range goes from the min
            to the max of the values of the enumerators.<br>
          </div>
        </blockquote>
        <div><br>
          Right, but `is_enumerator` is a functional superset of
          `is_in_enum_range`. Do people really need to ask <i>only</i>
          if a value is in the range of an enumerator?<br>
        </div>
      </div>
    </blockquote>
    I don't follow you. You surely wanted to say subset<br>
    <br>
    The standard says in 7.2/8 :
    <blockquote>
      <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Dutf=
-8">
      <div class=3D"page" title=3D"Page 190">
        <div class=3D"layoutArea">
          <div class=3D"column">
            <ol start=3D"6" style=3D"list-style-type: none">
              <li>
                <p><span style=3D"font-size: 7.000000pt; font-family:
                    'LMRoman7'; vertical-align: 2.000000pt">8 =C2=A0</span>=
<span
                    style=3D"font-size: 10.000000pt; font-family:
                    'LMRoman10'">For an enumeration whose underlying
                    type is fixed, the values of the enumeration are the
                    values of the
                    underlying type. Otherwise, for an enumeration where
                  </span><span style=3D"font-size: 10.000000pt;
                    font-family: 'LMMathItalic10'">e</span><span
                    style=3D"font-size: 7.000000pt; font-family:
                    'LMRoman7'; font-style: italic; vertical-align:
                    -1.000000pt">min </span><span style=3D"font-size:
                    10.000000pt; font-family: 'LMRoman10'">is the
                    smallest enumerator and </span><span
                    style=3D"font-size: 10.000000pt; font-family:
                    'LMMathItalic10'">e</span><span style=3D"font-size:
                    7.000000pt; font-family: 'LMRoman7'; font-style:
                    italic; vertical-align: -1.000000pt">max </span><span
                    style=3D"font-size: 10.000000pt; font-family:
                    'LMRoman10'">is the
                    largest, the values of the enumeration are the
                    values in the range </span><span style=3D"font-size:
                    10.000000pt; font-family: 'LMMathItalic10'">b</span><sp=
an
                    style=3D"font-size: 7.000000pt; font-family:
                    'LMMathItalic7'; vertical-align: -1.000000pt">min </spa=
n><span
                    style=3D"font-size: 10.000000pt; font-family:
                    'LMRoman10'">to </span><span style=3D"font-size:
                    10.000000pt; font-family: 'LMMathItalic10'">b</span><sp=
an
                    style=3D"font-size: 7.000000pt; font-family:
                    'LMMathItalic7'; vertical-align: -1.000000pt">max</span=
><span
                    style=3D"font-size: 10.000000pt; font-family:
                    'LMRoman10'">, defined as follows: Let </span><span
                    style=3D"font-size: 10.000000pt; font-family:
                    'LMMathItalic10'">K
                  </span><span style=3D"font-size: 10.000000pt;
                    font-family: 'LMRoman10'">be 1 for a two=E2=80=99s
                    complement representation and 0 for a ones=E2=80=99
                    complement or sign-magnitude representation.
                  </span><span style=3D"font-size: 10.000000pt;
                    font-family: 'LMMathItalic10'">b</span><span
                    style=3D"font-size: 7.000000pt; font-family:
                    'LMMathItalic7'; vertical-align: -1.000000pt">max </spa=
n><span
                    style=3D"font-size: 10.000000pt; font-family:
                    'LMRoman10'">is the smallest value greater than or
                    equal to </span><span style=3D"font-size:
                    10.000000pt; font-family: 'LMMathItalic10'">max</span><=
span
                    style=3D"font-size: 10.000000pt; font-family:
                    'LMRoman10'">(</span><span style=3D"font-size:
                    10.000000pt; font-family: 'LMMathSymbols10'">|</span><s=
pan
                    style=3D"font-size: 10.000000pt; font-family:
                    'LMMathItalic10'">e</span><span style=3D"font-size:
                    7.000000pt; font-family: 'LMMathItalic7';
                    vertical-align: -1.000000pt">min</span><span
                    style=3D"font-size: 10.000000pt; font-family:
                    'LMMathSymbols10'">| =E2=88=92 </span><span
                    style=3D"font-size: 10.000000pt; font-family:
                    'LMMathItalic10'">K, </span><span style=3D"font-size:
                    10.000000pt; font-family: 'LMMathSymbols10'">|</span><s=
pan
                    style=3D"font-size: 10.000000pt; font-family:
                    'LMMathItalic10'">e</span><span style=3D"font-size:
                    7.000000pt; font-family: 'LMMathItalic7';
                    vertical-align: -1.000000pt">max</span><span
                    style=3D"font-size: 10.000000pt; font-family:
                    'LMMathSymbols10'">|</span><span style=3D"font-size:
                    10.000000pt; font-family: 'LMRoman10'">) </span><span
                    style=3D"font-size: 10.000000pt; font-family:
                    'LMRoman10'">and equal to </span><span
                    style=3D"font-size: 10.000000pt; font-family:
                    'LMRoman10'">2</span><span style=3D"font-size:
                    7.000000pt; font-family: 'LMMathItalic7';
                    vertical-align: 4.000000pt">M </span><span
                    style=3D"font-size: 10.000000pt; font-family:
                    'LMMathSymbols10'">=E2=88=92 </span><span style=3D"font=
-size:
                    10.000000pt; font-family: 'LMRoman10'">1</span><span
                    style=3D"font-size: 10.000000pt; font-family:
                    'LMRoman10'">, where
                  </span><span style=3D"font-size: 10.000000pt;
                    font-family: 'LMMathItalic10'">M </span><span
                    style=3D"font-size: 10.000000pt; font-family:
                    'LMRoman10'">is a non-negative integer. </span><span
                    style=3D"font-size: 10.000000pt; font-family:
                    'LMMathItalic10'">b</span><span style=3D"font-size:
                    7.000000pt; font-family: 'LMMathItalic7';
                    vertical-align: -1.000000pt">min </span><span
                    style=3D"font-size: 10.000000pt; font-family:
                    'LMRoman10'">is zero if </span><span
                    style=3D"font-size: 10.000000pt; font-family:
                    'LMMathItalic10'">e</span><span style=3D"font-size:
                    7.000000pt; font-family: 'LMMathItalic7';
                    vertical-align: -1.000000pt">min </span><span
                    style=3D"font-size: 10.000000pt; font-family:
                    'LMRoman10'">is non-negative and </span><span
                    style=3D"font-size: 10.000000pt; font-family:
                    'LMMathSymbols10'">=E2=88=92</span><span style=3D"font-=
size:
                    10.000000pt; font-family: 'LMRoman10'">(</span><span
                    style=3D"font-size: 10.000000pt; font-family:
                    'LMMathItalic10'">b</span><span style=3D"font-size:
                    7.000000pt; font-family: 'LMMathItalic7';
                    vertical-align: -1.000000pt">max </span><span
                    style=3D"font-size: 10.000000pt; font-family:
                    'LMRoman10'">+ </span><span style=3D"font-size:
                    10.000000pt; font-family: 'LMMathItalic10'">K</span><sp=
an
                    style=3D"font-size: 10.000000pt; font-family:
                    'LMRoman10'">) </span><span style=3D"font-size:
                    10.000000pt; font-family: 'LMRoman10'">otherwise.
                    The size of
                    the smallest bit-field large enough to hold all the
                    values of the enumeration type is </span><span
                    style=3D"font-size: 10.000000pt; font-family:
                    'LMMathItalic10'">max</span><span style=3D"font-size:
                    10.000000pt; font-family: 'LMRoman10'">(</span><span
                    style=3D"font-size: 10.000000pt; font-family:
                    'LMMathItalic10'">M,</span><span style=3D"font-size:
                    10.000000pt; font-family: 'LMRoman10'">1) </span><span
                    style=3D"font-size: 10.000000pt; font-family:
                    'LMRoman10'">if </span><span style=3D"font-size:
                    10.000000pt; font-family: 'LMMathItalic10'">b</span><sp=
an
                    style=3D"font-size: 7.000000pt; font-family:
                    'LMMathItalic7'; vertical-align: -1.000000pt">min </spa=
n><span
                    style=3D"font-size: 10.000000pt; font-family:
                    'LMRoman10'">is
                    zero and </span><span style=3D"font-size:
                    10.000000pt; font-family: 'LMMathItalic10'">M </span><s=
pan
                    style=3D"font-size: 10.000000pt; font-family:
                    'LMRoman10'">+ 1 </span><span style=3D"font-size:
                    10.000000pt; font-family: 'LMRoman10'">otherwise. <b>It
                      is possible to define an enumeration that has
                      values not defined by any of its
                      enumerators.</b> If the </span><span
                    style=3D"font-size: 10.000000pt; font-family:
                    'LMRoman10'; font-style: italic">enumerator-list </span=
><span
                    style=3D"font-size: 10.000000pt; font-family:
                    'LMRoman10'">is empty, the values of the enumeration
                    are as if the enumeration had a
                    single enumerator with value 0.
                  </span></p>
              </li>
            </ol>
          </div>
        </div>
      </div>
      <title>C++ International Standa</title>
      <br>
    </blockquote>
    For me enumerators are any one of the named enum values. This set is
    a subset=C2=A0 not a superset of the range of valid values.<br>
    <br>
    As I said, until we don't have enums that consists only of the
    enumerators, there would be always the need to check if a value is a
    valid value for the enumeration.<br>
    <br>
    We could define a class that accepts only the enumerators as valid
    values, but the language enums can accept more values.<br>
    This is way I believe that the two checks are needed.<br>
    <br>
    I don't know why the new C++11 enum with an explicit underlying type
    have a different range of valid values.<br>
    I'll be interested in knowing the rationale.<br>
    <br>
    Vicente<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/040e99e3-8f07-409f-3a47-ebdfb2bfb465%=
40wanadoo.fr?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/040e99e3-8f07-409f-3a47-ebdfb2bfb465=
%40wanadoo.fr</a>.<br />

--------------BF1F89400088942B4377F680--

.
