220 32850 <ec30b779-62be-4bf6-aa93-51e281e93811@isocpp.org> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Mingxin Wang <wmx16835vv@163.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: std::enum
Date: Thu, 22 Jun 2017 20:18:53 -0700 (PDT)
Lines: 89
Approved: news@gmane.org
Message-ID: <ec30b779-62be-4bf6-aa93-51e281e93811@isocpp.org>
References: <1cdd0fbf-c65d-4034-82d1-a84d4c4f6d1c@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_204_941194325.1498187933254"
X-Trace: blaine.gmane.org 1498187935 12393 195.159.176.226 (23 Jun 2017 03:18:55 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Fri, 23 Jun 2017 03:18:55 +0000 (UTC)
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBDNMBNHJWIGBBHMRWLFAKGQEFGP47FA@isocpp.org Fri Jun 23 05:18:51 2017
Return-path: <std-proposals+bncBDNMBNHJWIGBBHMRWLFAKGQEFGP47FA@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-pf0-f198.google.com ([209.85.192.198])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBDNMBNHJWIGBBHMRWLFAKGQEFGP47FA@isocpp.org>)
	id 1dOF7S-0002x3-4T
	for gclcip-std-proposals@m.gmane.org; Fri, 23 Jun 2017 05:18:50 +0200
Original-Received: by mail-pf0-f198.google.com with SMTP id v62sf19022815pfd.10
        for <gclcip-std-proposals@m.gmane.org>; Thu, 22 Jun 2017 20:18:55 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=date:from:to:message-id:in-reply-to:references:subject:mime-version
         :x-original-sender:reply-to:precedence:mailing-list:list-id
         :list-post:list-help:list-archive:list-subscribe:list-unsubscribe;
        bh=ujy7rLZsfLHB9GzQwBhLKH5xCMtk+H6zO7Yj9b6UKoE=;
        b=Wpqbb5lKiYqBUlk7F1KvV8luiCuAwGHCcBlP2WWqT++kmRekeOgf53huYQPFTeTe8P
         mcc4LHEbWo0qKBq8hhcXudjMr1IZzYyVqm42AaRHqoB9mSq+LuLYuwAsQamNUqxzCvhJ
         NzlFiH2C/m8fjFA5w4UGeC8fRg1h7fjUAfjOkBiZWmr1Dyr/7qD3ozjzEVOrlZGAV7Py
         MtlhkC38bGYDFaFRuaW+8nKA+N8bLwOaZMun9llZHGgOq+7z1vcx/tsDkN/A6LVh7pAC
         k8IOKFc7fgN2yUn7X+YqgZaAh0qDsPPranmwcCgeQGLfumHAMRfeKVmrEQZZ03vreRwv
         UOyA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:date:from:to:message-id:in-reply-to:references
         :subject:mime-version:x-original-sender:reply-to:precedence
         :mailing-list:list-id:x-spam-checked-in-group:list-post:list-help
         :list-archive:list-subscribe:list-unsubscribe;
        bh=ujy7rLZsfLHB9GzQwBhLKH5xCMtk+H6zO7Yj9b6UKoE=;
        b=Lqf/uZvy+29hvRq3Q5EI0ueK2NoVbYm1kxakGfGnlSWEjCeLQkHa1c8E6BtsjL1bln
         CdfX1OyTKBoTuquzrs87E+Fbq8mDJRWHqyT2yixcNjaLFha9U0b/Fc/COXP9EZPgPmIS
         7ndpqxTqho7jWn+Hrt+yVDIA5LpayfamWzAHrk9igDjmoKJKkJRtDfz/xdlsNscAJO0c
         1dBgv3h92fnhU+6xpQE6E5PHNeX3qXD8aZYAW/+CO6bVebROUM1mMSh9OYvIQKNZyVCZ
         VwniSwVxL4guIsjFotzuH3SwXtN4Qbi6W1bYb19gu0K9QHgtmNLd6sFfHQTntpTmvZVW
         xe+A==
X-Gm-Message-State: AKS2vOzXwGcYxU8c6N645ogjY1Sh6vSZ5ieknb3UIYus3NKHXfjdGQjX
	9za/u1Y37pKGTGTz
X-Received: by 10.99.186.77 with SMTP id l13mr727646pgu.66.1498187934838;
        Thu, 22 Jun 2017 20:18:54 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.157.15.189 with SMTP id d58ls7561852otd.25.gmail; Thu, 22 Jun
 2017 20:18:53 -0700 (PDT)
X-Received: by 10.157.12.161 with SMTP id b30mr151568otb.3.1498187933852;
        Thu, 22 Jun 2017 20:18:53 -0700 (PDT)
In-Reply-To: <1cdd0fbf-c65d-4034-82d1-a84d4c4f6d1c@isocpp.org>
X-Original-Sender: wmx16835vv@163.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:32850
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/32850>

------=_Part_204_941194325.1498187933254
Content-Type: multipart/alternative; 
	boundary="----=_Part_205_1179142056.1498187933254"

------=_Part_205_1179142056.1498187933254
Content-Type: text/plain; charset="UTF-8"

On Wednesday, June 21, 2017 at 11:34:28 AM UTC+8, Halfdan Ingvarsson wrote:
>
> I'd like to propose a simple, but very useful utility class for the 
> standard library: std::enum.  
>
> All it does is take a template parameter, which would be an enum type.
>
> It would then allow you to access the individual elements of that enum, in 
> order of declaration, using a nearly identical interface as std::array<> 
> (i.e either through enumerators, or operator[]).
>
> Because this depends on new language features, I think the motivation in 
converting a "enum" to an array is not explicit enough.

As a user to the enum, I usually care "the mapping between names and 
values" more than "the order of declaration". Would it be more reasonable 
to convert an enum to an initializer list? For example:

enum E { ZERO = 0, ONE = 1, TWO = 2 };
std::map<std::string, int> a = MAKE_MAP(E); // MALE_MAP(E) is equivalent to 
{{"ZERO", 0}, {"ONE", 1}, {"TWO", 2}}

Still, I think there should be more motivation. As I can imagine, this 
feature is helpful in debugging and exception information generation.

Mingxin Wang

-- 
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/ec30b779-62be-4bf6-aa93-51e281e93811%40isocpp.org.

------=_Part_205_1179142056.1498187933254
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">On Wednesday, June 21, 2017 at 11:34:28 AM UTC+8, Halfdan =
Ingvarsson wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margi=
n-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"l=
tr">I&#39;d like to propose a simple, but very useful utility class for the=
 standard library: std::enum. =C2=A0<div><br></div><div>All it does is take=
 a template parameter, which would be an enum type.</div><div><br></div><di=
v>It would then allow you to access the individual elements of that enum, i=
n order of declaration, using a nearly identical interface as std::array&lt=
;&gt; (i.e either through enumerators, or operator[]).</div><div><div><br><=
/div></div></div></blockquote><div>Because this depends on new language fea=
tures, I think the motivation in converting a &quot;enum&quot; to an array =
is not explicit enough.</div><div><br></div><div>As a user to the enum, I u=
sually care &quot;the mapping between names and values&quot; more than &quo=
t;the order of declaration&quot;. Would it be more reasonable to convert an=
 enum to an initializer list? For example:</div><div><br></div><div><div cl=
ass=3D"prettyprint" style=3D"border: 1px solid rgb(187, 187, 187); word-wra=
p: break-word; background-color: rgb(250, 250, 250);"><code class=3D"pretty=
print"><div class=3D"subprettyprint"><div class=3D"subprettyprint">enum E {=
 ZERO =3D 0, ONE =3D 1, TWO =3D 2 };</div><div class=3D"subprettyprint">std=
::map&lt;std::string, int&gt; a =3D MAKE_MAP(E); // MALE_MAP(E) is equivale=
nt to {{&quot;ZERO&quot;, 0}, {&quot;ONE&quot;, 1}, {&quot;TWO&quot;, 2}}</=
div></div></code></div><br>Still, I think there should be more motivation. =
As I can imagine, this feature is helpful in debugging and exception inform=
ation generation.</div><div><br></div><div>Mingxin Wang</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/ec30b779-62be-4bf6-aa93-51e281e93811%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/ec30b779-62be-4bf6-aa93-51e281e93811=
%40isocpp.org</a>.<br />

------=_Part_205_1179142056.1498187933254--

------=_Part_204_941194325.1498187933254--

.
