220 29254 <1c81b80e-33b8-4de3-9bf7-94656e8b98f5@isocpp.org> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Nicol Bolas <jmckesson@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: explicit conversion from enum class to its
 underlying type
Date: Sun, 30 Oct 2016 05:20:39 -0700 (PDT)
Lines: 104
Approved: news@gmane.org
Message-ID: <1c81b80e-33b8-4de3-9bf7-94656e8b98f5@isocpp.org>
References: <4afed494-4fc5-4b06-b3e7-255aa293068e@isocpp.org>
 <f380095f-96be-d02f-584b-6821f70a20b2@wanadoo.fr>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_1323_584620306.1477830040015"
X-Trace: blaine.gmane.org 1477830057 18138 195.159.176.226 (30 Oct 2016 12:20:57 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Sun, 30 Oct 2016 12:20:57 +0000 (UTC)
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBCEKFTV6ZUMBBGGL27AAKGQESIFKGXQ@isocpp.org Sun Oct 30 13:20:53 2016
Return-path: <std-proposals+bncBCEKFTV6ZUMBBGGL27AAKGQESIFKGXQ@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-ua0-f200.google.com ([209.85.217.200])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBCEKFTV6ZUMBBGGL27AAKGQESIFKGXQ@isocpp.org>)
	id 1c0p6M-0002HZ-QW
	for gclcip-std-proposals@m.gmane.org; Sun, 30 Oct 2016 13:20:38 +0100
Original-Received: by mail-ua0-f200.google.com with SMTP id 23sf29053644uat.4
        for <gclcip-std-proposals@m.gmane.org>; Sun, 30 Oct 2016 05:20:41 -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
         :x-spam-checked-in-group:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=m7t+sgMz9TV44H52fLnNJuBcvjkbBNOfqqOgFxwKviY=;
        b=fNXlYkl1SJpibP5YquNwdSXKZyEa+drKk2XdpufZv2JonyOcvw5nBcQO1ZafKmUQRd
         q2VjEeDG0xqJwGLuy4y/alSY8iHBdXXoaVRYepMR6koBdR/Cw350BPaajj3NaRYS96vT
         GvQi5ovjLhW8tHNc0vuYIINDEkXVMvKu6FnUBtTqeFc+lwromXXRAQhzI8joCSKNH2ky
         e7YAsqmcSCUOgWMeC/zJAkFI9Q33c2dX6rTNZxCbPQbiSkigKLYxRFU9jBVzl45t113a
         oEwT/x9BJeb58HYJNIrBcBc++lhwNtzJdqedR0iQitVKWrs7GB06K5O4EbYOo0OgiONG
         BLsA==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20120113;
        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=m7t+sgMz9TV44H52fLnNJuBcvjkbBNOfqqOgFxwKviY=;
        b=YhYNdQLCAHr6nkTei8aJuftJWxQ16ZqQgWBQDdmb9NTrsDzxWlSfMe27yel9YtjWmX
         2odpFryGVp+F7HpG8aAtdT0trFfVSGGJQE/NWqNvBdMujnD7w42cewqb9JHP+7J6GKWI
         Ga9u5nbWPLCGm5/4jpXSyB/lCbZfDgyDGLpGTp/i5df6yy18lFJn2YerxZ8zI1YL3Pdq
         m8SRB49sqbJOoO/gdm/usz5h+ahH8qBXiganweqCcCaNnXoMcroJreuPoUPHWjC6db6K
         fpVif0qBHJLo0k3fkJPkbrZA88HD5mkAXK6IwgTjoX00Ckg+Xmv7ekOfXe2lkJtUDV65
         9d7A==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        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=m7t+sgMz9TV44H52fLnNJuBcvjkbBNOfqqOgFxwKviY=;
        b=Zj6NerzxhcCYbLyGxRRIHIXIws/tq1Y++WJiuwJH2butNNd7eMj7y6gNs+BC0uEKvK
         kCjmLcS28RHo/17Sx4mQ0PXSXHku7tS2W3zaf6u9rZGd2luVJqXBOd79YI3TTb0/CNk7
         cJgpVPKBVUz1AppladfsGCCZlts0YqRA9WxKAwcCXuA9mSWp9ADC9+liHADkoBua6Fp9
         o+Pkkp9drcIPs+RDqihqBW6b3B38dwdyMYWx9Jj6GB+doXT7Pi3IgBHlIynz9C8kykTb
         Kis7FSXZ8YhJTewhIwkS4ysZ30Rkjqmn9wc+TwScuRil1Wd0qodpOIM92C3VzCZmPro6
         mczw==
X-Gm-Message-State: ABUngvfJp7JpEg0+RttLwlf5jMgSnXTwjyvdOwZnrBcNjA6HoOL0ee0xOrFp1N+f/JlE6Q==
X-Received: by 10.176.6.37 with SMTP id f34mr8055751uaf.40.1477830041214;
        Sun, 30 Oct 2016 05:20:41 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.157.44.3 with SMTP id f3ls10423022otb.45.gmail; Sun, 30 Oct
 2016 05:20:40 -0700 (PDT)
X-Received: by 10.157.15.143 with SMTP id d15mr2463596otd.2.1477830040582;
        Sun, 30 Oct 2016 05:20:40 -0700 (PDT)
In-Reply-To: <f380095f-96be-d02f-584b-6821f70a20b2@wanadoo.fr>
X-Original-Sender: jmckesson@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:29254
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/29254>

------=_Part_1323_584620306.1477830040015
Content-Type: multipart/alternative; 
	boundary="----=_Part_1324_1011137650.1477830040015"

------=_Part_1324_1011137650.1477830040015
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable



On Sunday, October 30, 2016 at 3:50:18 AM UTC-4, Vicente J. Botet Escriba=
=20
wrote:
>
> Le 29/10/2016 =C3=A0 23:51, Andrzej Krzemie=C5=84ski a =C3=A9crit :
>
> Hi All,
>
> One of the nice safety features of enum classes is that they cannot be=20
> implicitly converted to their underlying type. However, do you think we=
=20
> would lose this safety feature if we allowed an explicit conversion to th=
e=20
> underlying type?
>
> I do not know of any practical use of explicit conversion operators excep=
t=20
> for the contextual conversion to bool. And it is only this conversion tha=
t=20
> I am interested in.
>
>
> This works already in a non-contextual conversion, isn't it?
>
>     bool(e)
>

No, it doesn't. The only way to convert a strongly typed enum to its=20
underlying type is with a `static_cast`.

--=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/1c81b80e-33b8-4de3-9bf7-94656e8b98f5%40isocpp.or=
g.

------=_Part_1324_1011137650.1477830040015
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><br>On Sunday, October 30, 2016 at 3:50:18 AM UTC-4, V=
icente J. Botet Escriba wrote:<blockquote class=3D"gmail_quote" style=3D"ma=
rgin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">
 =20
   =20
 =20
  <div bgcolor=3D"#FFFFFF" text=3D"#000000">
    <div>Le 29/10/2016 =C3=A0 23:51, Andrzej
      Krzemie=C5=84ski a =C3=A9crit=C2=A0:<br>
    </div>
    <blockquote type=3D"cite">
      <div dir=3D"ltr">Hi All,<br>
        <br>
        One of the nice safety features of enum classes is that they
        cannot be implicitly converted to their underlying type.
        However, do you think we would lose this safety feature if we
        allowed an explicit conversion to the underlying type?<br>
        <br>
        I do not know of any practical use of explicit conversion
        operators except for the contextual conversion to bool. And it
        is only this conversion that I am interested in.<br>
      </div>
    </blockquote>
    <br>
    This works already in a non-contextual conversion, isn&#39;t it?<br>
    <br>
    =C2=A0=C2=A0=C2=A0 bool(e)<br></div></blockquote><div><br>No, it doesn&=
#39;t. The only way to convert a strongly typed enum to its underlying type=
 is with a `static_cast`.<br></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/1c81b80e-33b8-4de3-9bf7-94656e8b98f5%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/1c81b80e-33b8-4de3-9bf7-94656e8b98f5=
%40isocpp.org</a>.<br />

------=_Part_1324_1011137650.1477830040015--

------=_Part_1323_584620306.1477830040015--

.
