220 30468 <edb1413c-5a47-39ff-0c17-587a27ca86f8@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 20:00:27 +0100
Lines: 69
Approved: news@gmane.org
Message-ID: <edb1413c-5a47-39ff-0c17-587a27ca86f8@wanadoo.fr>
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>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: quoted-printable
X-Trace: blaine.gmane.org 1484074838 26481 195.159.176.226 (10 Jan 2017 19:00:38 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Tue, 10 Jan 2017 19:00:38 +0000 (UTC)
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:45.0)
 Gecko/20100101 Thunderbird/45.6.0
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBDH67CONY4PBBTW62TBQKGQE4VPDM6I@isocpp.org Tue Jan 10 20:00:33 2017
Return-path: <std-proposals+bncBDH67CONY4PBBTW62TBQKGQE4VPDM6I@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+bncBDH67CONY4PBBTW62TBQKGQE4VPDM6I@isocpp.org>)
	id 1cR1em-0005t6-6V
	for gclcip-std-proposals@m.gmane.org; Tue, 10 Jan 2017 20:00:28 +0100
Original-Received: by mail-lf0-f70.google.com with SMTP id k86sf75397449lfi.4
        for <gclcip-std-proposals@m.gmane.org>; Tue, 10 Jan 2017 11:00:31 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=subject:to:references:from:message-id:date:user-agent:mime-version
         :in-reply-to:content-transfer-encoding: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=xe3I427El9CHNHg9ryT+ySNEl85PgDRp2acsrL0GS4w=;
        b=e8FJvZDgySBuWLO/VBG5xF0PDDwMGrhdyGxftRr/o2RjW2mINqpVvAgwO5Mlk8tNgI
         63l/LZXf3IkvTL7tbIzEBOM9Kbsq0H4QsuZJZBfpMTkpSaVjk52y44RUr00xrycVLKaW
         D+rZTpil3w6orquW55uXIR/fvDs1QlgGRVewp5NAzl5ROs6OaOdYSzqcxbMPQe5A02f2
         VOpIjM3Ce4azyu/qCOzOZWYZJpjXC4E1fSWTSaSV0tzeKetUvWdG9M95AsgtlU3r8uz9
         f2aB4eBbfb+UXW2sKgIHKcnnQMNrvUWpR+QV7uIvPMnyg86pidxGyn3MFwyKdVQWVIKm
      
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:from:message-id:date
         :user-agent:mime-version:in-reply-to:content-transfer-encoding
         :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=xe3I427El9CHNHg9ryT+ySNEl85PgDRp2acsrL0GS4w=;
        b=AwwCFZ845jruhpqaqChEqIEVnT2rD6iJhwifIm8jMavp4H94NKp8muX9HJe9OyMtqG
         X2pz94IAoyj7llAEtv97TPr2snJFGNJcBSfqYTuDl08FoMRH/DRA72H1oM+I4W4w8g8n
         xru8VfwdBMNNe6yS0527/QmLA40bcLX7uG3o3gFO2JB2e8PRoS/a1ceW02X0cm47gicT
         wt+PutIFot6GMNx7Li81iMV3sjUKhbdcPD16xYcxIzc7KESn0yCeWO9j/okPRuOvrcu1
         SNvQoDmLZw1VMjopXugDlBotfdcQKpnHqLzQ1/UQWU3/NwTtTmCLJf7HBaFQq84Ognhm
  
X-Gm-Message-State: AIkVDXLcOVTwNOkog5gha9IOTr73zPhyiVrdn25QfFZyTeCz6DRQLFo4cs6dsx0wx7Lehw==
X-Received: by 10.46.76.17 with SMTP id z17mr390529lja.5.1484074831379;
        Tue, 10 Jan 2017 11:00:31 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.28.13.14 with SMTP id 14ls426561wmn.15.gmail; Tue, 10 Jan 2017
 11:00:30 -0800 (PST)
X-Received: by 10.194.191.133 with SMTP id gy5mr3185240wjc.56.1484074830116;
        Tue, 10 Jan 2017 11:00:30 -0800 (PST)
Original-Received: from smtp.smtpout.orange.fr (smtp10.smtpout.orange.fr. [80.12.242.132])
        by mx.google.com with ESMTPS id b1si2352753wjz.272.2017.01.10.11.00.30
        for <std-proposals@isocpp.org>
        (version=TLS1 cipher=AES128-SHA bits=128/128);
        Tue, 10 Jan 2017 11:00:30 -0800 (PST)
Received-SPF: neutral (google.com: 80.12.242.132 is neither permitted nor denied by best guess record for domain of vicente.botet@wanadoo.fr) client-ip=80.12.242.132;
Original-Received: from imac-de-vicente-botet-escriba.home ([2.11.64.156])
	by mwinf5d20 with ME
	id Wj0U1u0053NGJZe03j0Vk3; Tue, 10 Jan 2017 20:00:29 +0100
X-ME-Helo: imac-de-vicente-botet-escriba.home
X-ME-Auth: dmljZW50ZS5ib3RldEB3YW5hZG9vLmZy
X-ME-Date: Tue, 10 Jan 2017 20:00:29 +0100
X-ME-IP: 2.11.64.156
In-Reply-To: <CANPtknwzegDLrDFrMoc5U9Z1y52PBZAC2BtQ=iS6Eur2A6f7NQ@mail.gmail.com>
X-Original-Sender: vicente.botet@wanadoo.fr
X-Original-Authentication-Results: mx.google.com;       spf=neutral
 (google.com: 80.12.242.132 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:30468
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/30468>

Le 10/01/2017 =C3=A0 18:01, Peter Koch Larsen a =C3=A9crit :
> Nicols proposal is very similar to mine, except that I do not have an
> enum_cast_opt. And I do not really see a reason to have this option.
> I believe that noone would use that option. Why write
>
> std::optional<Enum> e =3D enum_opt_cast<Enum>(x);
Because optional is a monad and you can do much more than checking for=20
whether it is present?
Anyway, all these functions could be defined in top of the checks.
> if (e)
> {
>      normal processing
> }
> else
> {
>      handle conversion failure
> }
>
> instead of
>
> if (is_enum<Enum>(e))
> {
>      Enum e =3D to_enum<Enum>(x);
>      normal processing
> }
> else
> {
>      handle conversion failure
> }
> ?
> Things to consider when implementing:
>
> What do you do if you have an enum with some same_valued elements
> (enum E { ea =3D 0, eb =3D 0})? My implementation forbids this.
What is the advantage to forbidding it.
> It could also be useful to have an ordinal position:
>
> enum E
> {
>   ea =3D 1000,
>   eb =3D -1000,
>   ec =3D 32
> };
>
> static_assert(to_ordinal<Enum>(ea) =3D=3D 0,"??");
> static_assert(to_ordinal<Enum>(eb) =3D=3D 1,"??");
> static_assert(to_ordinal<Enum>(ec) =3D=3D 2,"??");
I'm working on a proposal on ordinal types. We can consider that an enum=20
having all the enumerators different is an ordinal type if we consider=20
only these enumerators are valid. We could as well consider that any=20
Integral type is an ordinal type.
This proposal will include also the value associated to a position and=20
on top of that ordinal_array, ordinal_set and ordinal_range.

https://github.com/viboes/std-make/tree/master/include/experimental/fundame=
ntal/v3/ordinal

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/edb1413c-5a47-39ff-0c17-587a27ca86f8%40wanadoo.f=
r.

.
