220 30488 <CANPtkny2KM_jOaBb_wB1t0SBh2Sew+T2Ht+rUv95eXP562JY1A@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 20:23:08 +0100
Lines: 53
Approved: news@gmane.org
Message-ID: <CANPtkny2KM_jOaBb_wB1t0SBh2Sew+T2Ht+rUv95eXP562JY1A@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> <CANPtknxx9BXfwLagcO1ucu4pwi6PS6ewrdPzQsqOXgPUGuR-og@mail.gmail.com>
 <58764E08.10000@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 1484162597 25924 195.159.176.226 (11 Jan 2017 19:23:17 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Wed, 11 Jan 2017 19:23:17 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBDRIBXXKZQERBHUM3LBQKGQE5GBWVTQ@isocpp.org Wed Jan 11 20:23:09 2017
Return-path: <std-proposals+bncBDRIBXXKZQERBHUM3LBQKGQE5GBWVTQ@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-qt0-f199.google.com ([209.85.216.199])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBDRIBXXKZQERBHUM3LBQKGQE5GBWVTQ@isocpp.org>)
	id 1cROUE-0005rN-BQ
	for gclcip-std-proposals@m.gmane.org; Wed, 11 Jan 2017 20:23:06 +0100
Original-Received: by mail-qt0-f199.google.com with SMTP id a29sf129499790qtb.6
        for <gclcip-std-proposals@m.gmane.org>; Wed, 11 Jan 2017 11:23:11 -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=3aepIYIVbb96PVz0rLx+Fo3VP7dbn+HGAyq8lrRFJDw=;
        b=TeJD9e7JTZI0BWyWZkcanBtYcUB17HaOEkLHhO8Rfjih2aDbGR5KqC8blShd+pRMDu
         J5eND33+ztLyAwAU/B0NbRQM0X8gzhQJl8R2exdgq+9V9jSp9dz4Y8cPMSwMTHhGJIwZ
         qngzuhtx7h7o7WDZH1azaL5Gx/PGW+9KA7k4fsVgahaBrksjth632LUuFUv6QHc+GErT
         Eiw1jCJeaxtX1PByg+wAzAHN8WwzRbti8oIcOjXZR+7L+zE0rI1LV890g8auu8NcXRSy
         4PW611bEteXhCS5jc7LTtaTItd7jn1grCAXmpjd6lrvDItlJ1ltyt36BfoKYK4lzmd1X
         jS+A==
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=3aepIYIVbb96PVz0rLx+Fo3VP7dbn+HGAyq8lrRFJDw=;
        b=RwFVENuza4Jn4bjvPHzdFOUDiUl8rths3XQ/i3RyPykDlJQqpnnlym0XWBk/Q77i66
         gSAIOjVuTrs7Fdz6CjBXt7C78w3d+ELFQS84pXgrKhAxb4Z7f8MUDfE+TRqZnmBzfGan
         I5mVoiU+to9YC2mAEebBdnwV3eUXuLKVKTOd8BJ7cejJlL1wKW+lShLIOofCGTiBXfVa
         R6dYSKHU+GsCVZ65ikDpXgJdGYCW7faPYKGjTb5tse/orrkqlXEM4c1pJLr64Ta+eO+c
         ygBuVfcFLq+81i4eostvpRFsIuvJQn4C0oUeeMi/9Fs67FI6aRkCCLCjkzOfBW68oHfs
         quUA==
X-Gm-Message-State: AIkVDXIRBdqwDzjrInEjt7EwRRnCZnWybjkWIQcLICIYMkSTQURN3IJLHkfRC2iTSpMkKg==
X-Received: by 10.200.41.168 with SMTP id 37mr3011277qts.6.1484162590736;
        Wed, 11 Jan 2017 11:23:10 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.157.17.154 with SMTP id v26ls4858265otf.0.gmail; Wed, 11 Jan
 2017 11:23:09 -0800 (PST)
X-Received: by 10.31.53.134 with SMTP id c128mr3973316vka.13.1484162589924;
        Wed, 11 Jan 2017 11:23:09 -0800 (PST)
Original-Received: from mail-vk0-x22c.google.com (mail-vk0-x22c.google.com. [2607:f8b0:400c:c05::22c])
        by mx.google.com with ESMTPS id h20si1815525vke.193.2017.01.11.11.23.09
        for <std-proposals@isocpp.org>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Wed, 11 Jan 2017 11:23:09 -0800 (PST)
Received-SPF: pass (google.com: domain of peter.koch.larsen@gmail.com designates 2607:f8b0:400c:c05::22c as permitted sender) client-ip=2607:f8b0:400c:c05::22c;
Original-Received: by mail-vk0-x22c.google.com with SMTP id 137so386739023vkl.0
        for <std-proposals@isocpp.org>; Wed, 11 Jan 2017 11:23:09 -0800 (PST)
X-Received: by 10.31.73.66 with SMTP id w63mr4991096vka.106.1484162589419;
 Wed, 11 Jan 2017 11:23:09 -0800 (PST)
Original-Received: by 10.103.11.5 with HTTP; Wed, 11 Jan 2017 11:23:08 -0800 (PST)
In-Reply-To: <58764E08.10000@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:c05::22c 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:30488
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/30488>

On Wed, Jan 11, 2017 at 4:23 PM, Matthew Woehlke
<mwoehlke.floss@gmail.com> wrote:
> On 2017-01-11 02:58, Peter Koch Larsen wrote:
>> On Tue, Jan 10, 2017 at 7:31 PM, Matthew Woehlke 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.
>
> ...but you will *also* get `ea` back. The values `ea` and `eb` are not
> distinguishable when represented as either the enum nor as an integer
> (via value cast). They are only distinguishable as strings or ordinals.
>
And?

> If that isn't what you want, don't give your enum multiple identifiers
> with the same value in the first place.

I don't. ;-)

>
>
> So just *don't do that*. But don't artificially nerf your proposed
> feature for people that *do* find that useful.

Well, I have not proposed anything here - perhaps you should reread this thread?
I simply gave an outline as to how I implemented a feature that was
close to what is proposed, and tried to bring to attention some of
the open questions I experienced while doing that.
Personally, I would prefer to not standardize enum_cast. My preference
would be to wait for reflection to be implemented. At that point it
will probably just be a simple library function.

/Peter

-- 
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/CANPtkny2KM_jOaBb_wB1t0SBh2Sew%2BT2Ht%2BrUv95eXP562JY1A%40mail.gmail.com.

.
