220 30218 <1730f9cb-837d-4af3-a771-107e21de0adc@isocpp.org> article
Path: news.gmane.org!.POSTED!not-for-mail
From: m.cencora@gmail.com
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: enum_cast proposal
Date: Wed, 4 Jan 2017 00:44:09 -0800 (PST)
Lines: 157
Approved: news@gmane.org
Message-ID: <1730f9cb-837d-4af3-a771-107e21de0adc@isocpp.org>
References: <efdf2357-00a6-408a-8772-12f99135a880@isocpp.org> <2998762.etaySSRi7N@tjmaciei-mobl1> <d4b84145-05e8-452f-ba08-dae9bbe34e04@isocpp.org>
 <42463446.MPeEFdAbRV@tjmaciei-mobl1>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_2725_666972437.1483519450024"
X-Trace: blaine.gmane.org 1483519456 6868 195.159.176.226 (4 Jan 2017 08:44:16 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Wed, 4 Jan 2017 08:44:16 +0000 (UTC)
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBD7YFUMJRYMBBWXLWLBQKGQEKBVD4SY@isocpp.org Wed Jan 04 09:44:12 2017
Return-path: <std-proposals+bncBD7YFUMJRYMBBWXLWLBQKGQEKBVD4SY@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-yb0-f197.google.com ([209.85.213.197])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBD7YFUMJRYMBBWXLWLBQKGQEKBVD4SY@isocpp.org>)
	id 1cOhB1-0000QJ-8r
	for gclcip-std-proposals@m.gmane.org; Wed, 04 Jan 2017 09:44:07 +0100
Original-Received: by mail-yb0-f197.google.com with SMTP id 186sf402442659yby.5
        for <gclcip-std-proposals@m.gmane.org>; Wed, 04 Jan 2017 00:44:11 -0800 (PST)
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
         :x-spam-checked-in-group:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=XMwqCEIWm3hVdGE46aLG5dRMOTUnREI1bvixKrT2zaQ=;
        b=gEgdiOmxLEDWXqydfzlpAb18//vr1OTDEiCBeNd5CVuA8JbtYoHO1Gx1TQtc1ErSkr
         vtt/t9n0dCAPxMelDYI/cdCSqz7o3TI8q3FRK2zrbxkbbCaDV+8AT1w4nkLfu/2wbKBO
         6ugeDva0ry/HPLntoMB6OUqbTVU6+pQoiXPr4vgDp9p2b0djfW1WU0RXQ24jS+Pg/CBG
         ocGyZnBy5eMO4jXtoKid6+NdmL7djeEl5gvGF1PxB7FOHz9EcRjpVXkkfvGnjqdIPZbd
         M9owwtvyHpmFRaoZJ+0DpO6/ExVEMYQ+muAZ+hQPVMx4JPGa0LV948pJddgZX0BU4E0/
         954Q==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20161025;
        h=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=XMwqCEIWm3hVdGE46aLG5dRMOTUnREI1bvixKrT2zaQ=;
        b=EGaQBZtGYVjWv1ZSXEPntcSfrx00H7KudIBcUKDwgpcWjKn0rOPpwsEmTIumM2xclr
         8hVSx3/xBGZShEMvhOgRTbDKTYhaUhrzDv9xXAtoxR07RvhyEvDkLiA573nI9qrpK8wM
         kpX3flev029wmZEQYfbNLG1yBbB3aDbeXK0UYfax54krtd8m+9ZpLyTzvRV4BLCGwW/e
         F4ZmFFylA4zsd4riA+waazsjwWWLOv95ZlBnsvfNXLQSdm7SEGaVEDHdgiDtd6BYgIiJ
         40Z/OrVkt5bsTay88jfnSlOf2+m28UspI11dswbGSVObLYl087pwRDSyVV0+U3DrycZl
         ufxw==
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=XMwqCEIWm3hVdGE46aLG5dRMOTUnREI1bvixKrT2zaQ=;
        b=ok+bmRTFJzS5EeVLjMLqB0TxsYrD1gPRrcvKQpQRiJE5Xae5ipOPTuBCfZPr7FXYfz
         GdD4bQYmPYsFeU2FRJg87G/Et1pb6c2XzAz8sSmj4stc7V3wjMRzohwfousQDigKxSTP
         IERqwL5/6D1O7T39MyPgpKgfMmUgHql3iYHPaXRgUE5++CuFr5mmk1lDRotErQOMzlLb
         vqAsDlYe19qs+O0mFpza6gE+sbgt4zI+ShWMFz0CSKIgVpEITtOSjZI2Eu+1eCjZqR30
         AMHQU5bEtkwnZ1rPfFeaHFHAMpjtm2c9gWNGhz2xD+dhEEQQROAft85AR8o/sTGswkn4
         9nhw==
X-Gm-Message-State: AIkVDXIxmwBrqbRZk3rZVJ5dOJWctp6ugkoxRnqjRfO5hQlgd9r9w6YE6hLw8gfGS1rR7A==
X-Received: by 10.129.96.67 with SMTP id u64mr19264209ywb.90.1483519451158;
        Wed, 04 Jan 2017 00:44:11 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.157.11.115 with SMTP id p48ls19808739otd.19.gmail; Wed, 04 Jan
 2017 00:44:10 -0800 (PST)
X-Received: by 10.157.17.3 with SMTP id g3mr3040149ote.8.1483519450433;
        Wed, 04 Jan 2017 00:44:10 -0800 (PST)
In-Reply-To: <42463446.MPeEFdAbRV@tjmaciei-mobl1>
X-Original-Sender: m.cencora@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:30218
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/30218>

------=_Part_2725_666972437.1483519450024
Content-Type: multipart/alternative; 
	boundary="----=_Part_2726_901685433.1483519450024"

------=_Part_2726_901685433.1483519450024
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

W dniu wtorek, 3 stycznia 2017 20:12:38 UTC+1 u=C5=BCytkownik Thiago Maciei=
ra=20
napisa=C5=82:
>
> On ter=C3=A7a-feira, 3 de janeiro de 2017 08:22:52 BRST m.ce...@gmail.com=
=20
> <javascript:> wrote:=20
> > > How do you know whether a use of enum_cast is compile-time or whether=
=20
> it=20
> > > is=20
> > > runtime?=20
> >=20
> > I don't know and I don't care. The function should be constexpr to=20
> support=20
> > both cases.=20
>
> Well, I think people may care. A constexpr invocation has zero cost at=20
> runtime, since it will have failed to convert by producing an error=20
> message,=20
> or it will succeed by becoming a no-op (like static_cast, minus pointer=
=20
> adjustment). But a non-constexpr invocation will have a runtime cost.=20
>

Well of course it will have runtime cost in non-constexpr invocation, the
whole point of this function is to perform validation at runtime.
Constexpr support is just an addition.
=20

> > What I'd like to hear now is whether anyone else would find such a=20
> > functionality useful?=20
> > Do you consider it a good idea to put it into C++ standard/library?=20
>
> Maybe you should rename it to mean a check if the value is a valid=20
> enumerator=20
> and drop the "cast" part.=20
>

I thought about it, but I see no use case for just a check.
In all the use cases I can think of user wants the cast after the check.

Do you have a example in mind where such a check without a cast later
would be useful?
=20

>
> --=20
> Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org=20
>    Software Architect - Intel Open Source Technology Center=20
>
>

--=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/1730f9cb-837d-4af3-a771-107e21de0adc%40isocpp.or=
g.

------=_Part_2726_901685433.1483519450024
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">W dniu wtorek, 3 stycznia 2017 20:12:38 UTC+1 u=C5=BCytkow=
nik Thiago Macieira napisa=C5=82:<blockquote class=3D"gmail_quote" style=3D=
"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex=
;">On ter=C3=A7a-feira, 3 de janeiro de 2017 08:22:52 BRST <a href=3D"javas=
cript:" target=3D"_blank" gdf-obfuscated-mailto=3D"duJh4IyBCwAJ" rel=3D"nof=
ollow" onmousedown=3D"this.href=3D&#39;javascript:&#39;;return true;" oncli=
ck=3D"this.href=3D&#39;javascript:&#39;;return true;">m.ce...@gmail.com</a>=
 wrote:
<br>&gt; &gt; How do you know whether a use of enum_cast is compile-time or=
 whether it
<br>&gt; &gt; is
<br>&gt; &gt; runtime?
<br>&gt;=20
<br>&gt; I don&#39;t know and I don&#39;t care. The function should be cons=
texpr to support
<br>&gt; both cases.
<br>
<br>Well, I think people may care. A constexpr invocation has zero cost at=
=20
<br>runtime, since it will have failed to convert by producing an error mes=
sage,=20
<br>or it will succeed by becoming a no-op (like static_cast, minus pointer=
=20
<br>adjustment). But a non-constexpr invocation will have a runtime cost.
<br></blockquote><div><br></div><div>Well of course it will have runtime co=
st in non-constexpr invocation, the</div><div>whole point of this function =
is to perform validation at runtime.</div><div>Constexpr support is just an=
 addition.</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=
;">&gt; What I&#39;d like to hear now is whether anyone else would find suc=
h a
<br>&gt; functionality useful?
<br>&gt; Do you consider it a good idea to put it into C++ standard/library=
?
<br>
<br>Maybe you should rename it to mean a check if the value is a valid enum=
erator=20
<br>and drop the &quot;cast&quot; part.
<br></blockquote><div><br></div><div>I thought about it, but I see no use c=
ase for just a check.</div><div>In all the use cases I can think of user wa=
nts the cast after the check.</div><div><br></div><div>Do you have a exampl=
e in mind where such a check without a cast later</div><div>would be useful=
?</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;">
<br>--=20
<br>Thiago Macieira - thiago (AT) <a href=3D"http://macieira.info" target=
=3D"_blank" rel=3D"nofollow" onmousedown=3D"this.href=3D&#39;http://www.goo=
gle.com/url?q\x3dhttp%3A%2F%2Fmacieira.info\x26sa\x3dD\x26sntz\x3d1\x26usg\=
x3dAFQjCNEswDUBNCNanbu7euhqLn_62FW8ag&#39;;return true;" onclick=3D"this.hr=
ef=3D&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fmacieira.info\x26sa\x=
3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEswDUBNCNanbu7euhqLn_62FW8ag&#39;;return t=
rue;">macieira.info</a> - thiago (AT) <a href=3D"http://kde.org" target=3D"=
_blank" rel=3D"nofollow" onmousedown=3D"this.href=3D&#39;http://www.google.=
com/url?q\x3dhttp%3A%2F%2Fkde.org\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNH=
GRJdo5_JYG1DowztwAHAKs80XSA&#39;;return true;" onclick=3D"this.href=3D&#39;=
http://www.google.com/url?q\x3dhttp%3A%2F%2Fkde.org\x26sa\x3dD\x26sntz\x3d1=
\x26usg\x3dAFQjCNHGRJdo5_JYG1DowztwAHAKs80XSA&#39;;return true;">kde.org</a=
>
<br>=C2=A0 =C2=A0Software Architect - Intel Open Source Technology Center
<br>
<br></blockquote></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/1730f9cb-837d-4af3-a771-107e21de0adc%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/1730f9cb-837d-4af3-a771-107e21de0adc=
%40isocpp.org</a>.<br />

------=_Part_2726_901685433.1483519450024--

------=_Part_2725_666972437.1483519450024--

.
