220 30474 <CANPtknxx9BXfwLagcO1ucu4pwi6PS6ewrdPzQsqOXgPUGuR-og@mail.gmail.com> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Peter Koch Larsen <peter.koch.larsen@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Re: enum_cast proposal
Date: Wed, 11 Jan 2017 08:58:03 +0100
Lines: 43
Approved: news@gmane.org
Message-ID: <CANPtknxx9BXfwLagcO1ucu4pwi6PS6ewrdPzQsqOXgPUGuR-og@mail.gmail.com>
References: <efdf2357-00a6-408a-8772-12f99135a880@isocpp.org>
 <57258435-5d82-48e7-8ed7-3c38682418fb@isocpp.org> <a35d9f20-9e4f-4789-b7e5-5cb08f99e6bd@isocpp.org>
 <58750288.5080004@gmail.com> <e85f0d46-f244-42fe-a276-b4e18b3d627f@isocpp.org>
 <CANPtknwzegDLrDFrMoc5U9Z1y52PBZAC2BtQ=iS6Eur2A6f7NQ@mail.gmail.com> <5875286B.7040604@gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
X-Trace: blaine.gmane.org 1484121486 29179 195.159.176.226 (11 Jan 2017 07:58:06 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Wed, 11 Jan 2017 07:58:06 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBDRIBXXKZQERBDGL27BQKGQE6CNOXSQ@isocpp.org Wed Jan 11 08:58:02 2017
Return-path: <std-proposals+bncBDRIBXXKZQERBDGL27BQKGQE6CNOXSQ@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-it0-f71.google.com ([209.85.214.71])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBDRIBXXKZQERBDGL27BQKGQE6CNOXSQ@isocpp.org>)
	id 1cRDnE-0006zw-Ke
	for gclcip-std-proposals@m.gmane.org; Wed, 11 Jan 2017 08:58:00 +0100
Original-Received: by mail-it0-f71.google.com with SMTP id p189sf152650562itg.2
        for <gclcip-std-proposals@m.gmane.org>; Tue, 10 Jan 2017 23:58:05 -0800 (PST)
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=42FmYhh91mZT3K2JOHEAiJj8qTO3LKnAIbEvec7jOW0=;
        b=KvXnuDiZXLrH7BW42Alf3gQ1EaxxYZ0HhuNglzSDNWbrKH3wa9Hnjjb4n4xx6/o9n5
         rUpNMMNVbfJ3spUXsj9t6nTBhbJMfenA2e6H5gqJYSLb4sU5X5XqBpa0kWBLuznflCsY
         7gkF4foLXyOXk6UHZ7wHvUAuRvEDec+ptQrQx6SK2wb52QcOFiiwmFibCcSEV6DORdL3
         oVRR5+Y2nPMNklvCgjfzHFzGbmWqrPeaNr8wYopOjPpQaJ8TK6S3CcUk2zl7PI0JJLJT
         XmvH3dafnQgAZbkcRxAYzvA8Bt5PEZ9pz6iVY66HtJ3UPyDIavczANM84MlZCKnAXCv1
         UZkw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        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=42FmYhh91mZT3K2JOHEAiJj8qTO3LKnAIbEvec7jOW0=;
        b=GZCR/DTSOdkwOsAFfwT9U7jNCmmrtrqrx8iyR6ZAe06f4R+N42kTVK3Km4x5mQUfY4
         8ntdXZRprQpi1JzEm5+DyzKVFxIC8lguNfwOze2F0Hyd657t58CusOe189uUTpNcLmHf
         vl+Z5l/VspMULJDERMvt6qBh8f+wCwyLdu03TB0Uv2rn4Ds+4j+vHWMAty0RQV5CFp5j
         l1qljuM9j7QQHcaTZ4c9kKDowCMA8sAD4uTGDeu9pLacpD3BWbiHZMiXht7CN9sFw5sZ
         C5marO/5cKTv5VdpayKlLNVk8wvi4QY09sSITQtCkHJhN4BmVPsxoH1vcbj9qu4/Fd2N
         dOTw==
X-Gm-Message-State: AIkVDXKmmPhyCphMv4db+BdM+bqNStJK/TilAALVPD8D+V/J2ML6QT0ryFkrjZZBWknShg==
X-Received: by 10.36.39.196 with SMTP id g187mr5130221ita.14.1484121484940;
        Tue, 10 Jan 2017 23:58:04 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.157.5.41 with SMTP id 38ls855107otw.35.gmail; Tue, 10 Jan 2017
 23:58:04 -0800 (PST)
X-Received: by 10.176.3.196 with SMTP id 62mr3376561uau.120.1484121484315;
        Tue, 10 Jan 2017 23:58:04 -0800 (PST)
Original-Received: from mail-ua0-x234.google.com (mail-ua0-x234.google.com. [2607:f8b0:400c:c08::234])
        by mx.google.com with ESMTPS id d13si762078uag.37.2017.01.10.23.58.04
        for <std-proposals@isocpp.org>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Tue, 10 Jan 2017 23:58:04 -0800 (PST)
Received-SPF: pass (google.com: domain of peter.koch.larsen@gmail.com designates 2607:f8b0:400c:c08::234 as permitted sender) client-ip=2607:f8b0:400c:c08::234;
Original-Received: by mail-ua0-x234.google.com with SMTP id 96so80642767uaq.3
        for <std-proposals@isocpp.org>; Tue, 10 Jan 2017 23:58:04 -0800 (PST)
X-Received: by 10.176.71.5 with SMTP id h5mr3956590uac.167.1484121483972; Tue,
 10 Jan 2017 23:58:03 -0800 (PST)
Original-Received: by 10.103.11.5 with HTTP; Tue, 10 Jan 2017 23:58:03 -0800 (PST)
In-Reply-To: <5875286B.7040604@gmail.com>
X-Original-Sender: peter.koch.larsen@gmail.com
X-Original-Authentication-Results: mx.google.com;       dkim=pass
 header.i=@gmail.com;       spf=pass (google.com: domain of
 peter.koch.larsen@gmail.com designates 2607:f8b0:400c:c08::234 as permitted
 sender) smtp.mailfrom=peter.koch.larsen@gmail.com;       dmarc=pass (p=NONE
 sp=NONE dis=NONE) header.from=gmail.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:30474
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/30474>

On Tue, Jan 10, 2017 at 7:31 PM, Matthew Woehlke
<mwoehlke.floss@gmail.com> wrote:
> On 2017-01-10 12:01, Peter Koch Larsen wrote:
>> What do you do if you have an enum with some same_valued elements
>> (enum E { ea = 0, eb = 0})? My implementation forbids this.
>
> Why?
>
>   E x = ea;
>   assert(x == eb); // will succeed
>
> Such a prohibition makes some sense when converting an enum to a string
> (or to its ordinal), but there is no problem when converting an int to
> an enum (or a string to an enum, for that matter).

This is exactly my problem. I partially use my library in to do this
stuff, and it could be confusing for the user if you serialize as ea
and get eb back. I also have a bitset class (enum_bitset<Enum>), where
I as a template parameter define if i set the bit depending on the
underlying enums ordinal values or by its underlying integral value.
In neither case do I see any use of having two enums with the same
value.
Also, I do not see a reason in have two enums with the same value.
Before my library, I would have two underlying enums with the same
value in two situations: To have a count (e.g. enum color {
red,green,blue, color_count = blue} or to name bit-sets enum state {
created = 1, received = 2, sent = 4, active = created}). These reasons
are both gone now.

/Peter


>
> --
> Matthew
>

-- 
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/CANPtknxx9BXfwLagcO1ucu4pwi6PS6ewrdPzQsqOXgPUGuR-og%40mail.gmail.com.

.
