220 33451 <CAGNvRgDH=eef=TWoXor1MedUw9xBzm3bgSZKqsREN_-qaxTC_w@mail.gmail.com> article
Path: news.gmane.org!.POSTED!not-for-mail
From: =?UTF-8?Q?Daniel_Kr=C3=BCgler?= <daniel.kruegler@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Proposal: underlying_cast
Date: Sun, 30 Jul 2017 19:05:26 +0200
Lines: 65
Approved: news@gmane.org
Message-ID: <CAGNvRgDH=eef=TWoXor1MedUw9xBzm3bgSZKqsREN_-qaxTC_w@mail.gmail.com>
References: <6a2c32ed-99b5-4cc5-86a5-ee3cc07567a3@isocpp.org>
 <2570492.NpxuI0RVu0@tjmaciei-mobl1> <CAFk2RUaZt4e9cKe4huBs09Na9aKkzJb4xdvtpRvSXH03SQjbyw@mail.gmail.com>
 <CAGNvRgDSBrxKcdDcxL=M60e=xNcTufZPAgeSAW0adpR_yAkeYQ@mail.gmail.com> <CAFk2RUaQ-BG4+y0N2GiEDsVNLBUsb2-_bmgid6=qcEt5N0e_Mw@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"
Content-Transfer-Encoding: quoted-printable
X-Trace: blaine.gmane.org 1501434331 16213 195.159.176.226 (30 Jul 2017 17:05:31 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Sun, 30 Jul 2017 17:05:31 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBCT7RVFA4QORBV5D7DFQKGQEZKOVVCA@isocpp.org Sun Jul 30 19:05:24 2017
Return-path: <std-proposals+bncBCT7RVFA4QORBV5D7DFQKGQEZKOVVCA@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+bncBCT7RVFA4QORBV5D7DFQKGQEZKOVVCA@isocpp.org>)
	id 1dbrec-0003jb-L6
	for gclcip-std-proposals@m.gmane.org; Sun, 30 Jul 2017 19:05:22 +0200
Original-Received: by mail-lf0-f70.google.com with SMTP id 42sf55683723lfq.10
        for <gclcip-std-proposals@m.gmane.org>; Sun, 30 Jul 2017 10:05:29 -0700 (PDT)
ARC-Seal: i=2; a=rsa-sha256; t=1501434328; cv=pass;
        d=google.com; s=arc-20160816;
        b=u72t86eTR9KpsuZ1NlxG5Xy58XN9Oiqq4H5+5j02il0hy4yLlHiW7j7zc53v85cXdn
         EzKq4PlvlvMLR2OLbZuebSoOYmOhDwKMF/EHgXLlxC4CfQP/XHWqWA4QJkCBYxHEAoEv
         B7A6pGzIhnNUhpa+XwyAJiwaU5ZijYmnBsT/65gPdxxTGRR+LeXESau6jW33YQAEy6S1
         /DBGSB/Q6hNf14Lg8EnnLMVXMYQblyoWZhD+Se0ieu7pnaTcHXCbP7ZOKPcxIOKIe2TJ
         2qgBo5GtWM+UtHeEX7tEYrZnHN5ecrnhR/7+0jS4jibbn7L+WjqS9M9EBG8pmV6CxJra
         v8Ig==
ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
        h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post
         :list-id:mailing-list:precedence:reply-to:content-transfer-encoding
         :to:subject:message-id:date:from:references:in-reply-to:mime-version
         :arc-authentication-results:arc-message-signature:dkim-signature
         :arc-authentication-results;
        bh=axxyUStvfOMhtPUU8zdQYxZEpui/pfAIMXPULzUbgss=;
        b=DQccf7ACZ2S5F68KKd7Apl3tAW4TtJ2ECFSuchK/2CaZO3vVp7MgJMAKPlCA8IdhTj
         6iR4CRCm+rIIYIzp2+V069320nRUrlN1tD5P72GFNWuirNBLvoqMe82DGxISQKSQx+gi
         M9nuJzSmTifoOUmjlbOo3g/ScDdwVrGrkP1FOnDPSybWMHLAq+3da3Q1p73FQsBil8qu
         pbHZYPCr8I7ezEKIKyidBzr/rn3Dqg1+/aYhoKdyCFgHHgI34ENs2hWqDh+9WpgI1pP5
         9caQGLbckuxHyqP7phAa7eP1Mr1MhDEr7eQBoj1E3fLNXqJtESL5bXmGtvl7lPyNPh9N
         1pYw==
ARC-Authentication-Results: i=2; mx.google.com;
       dkim=pass header.i=@gmail.com header.s=20161025 header.b=uWg1+rwi;
       spf=pass (google.com: domain of daniel.kruegler@gmail.com designates 2a00:1450:400c:c0c::236 as permitted sender) smtp.mailfrom=daniel.kruegler@gmail.com;
       dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com
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
         :content-transfer-encoding:x-original-sender
         :x-original-authentication-results:reply-to:precedence:mailing-list
         :list-id:list-post:list-help:list-archive:list-subscribe
         :list-unsubscribe;
        bh=axxyUStvfOMhtPUU8zdQYxZEpui/pfAIMXPULzUbgss=;
        b=sIriCntXOnVwoK0DJFzlecab9fWOesNGErmFwlu9nEw6w7xVj0cE6mu+C1sPAzrfMZ
         TkbSBbNdN2lxXC0ZB52HDHKYFivGUlKgH273CmoEMZyNZnJspFnGzfU/xE4yDmhZ9dvv
         D6QouujsjAOCIFiLT0QOx9OOVi1uu4DPmEUbo8RoeouwHBvvGN3Hdav0fQrWbhBXLzX1
         XjdfJCHChTnQH//nqS0Yb6E5Zqz8Kqbk6jnOi/n91l+Biz7DZlihbtnACwcUAUOnqSz5
         Q1XYGB9J3gtD101NErhzg1QwzA33ajZIAR4JvtCsbhB7mTCbqL/NL5IO7XiK4C/BjvGZ
         NQDA==
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: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=axxyUStvfOMhtPUU8zdQYxZEpui/pfAIMXPULzUbgss=;
        b=mGQwIxiat4+azSldVUOUm16RQ4b3k+H2SkA5a9Sg5CV/aZaADidjtKdKpsvHv4EjhR
         7iSa5PtajJj9Qg0C38Sb27WKEzhl3o8YcUnCD4CmwAlPurvGl8FXjcgLtTHSKdW4wm1X
         JNgf0HSw9NnWcOA5JyRcsP213U0ajlqr8RR3g8epwP2YRUyubY9Odej2I5jGD0+JaR2u
         uwyFXs0itRvvb42luBERcA2eoWdjeg/Y8mDUwCt81VY4B5tgb5qpOR7+L0p3hfW5B5Js
         gMNtk6ra1UQWm8CXHscGGEWZEEmDIarRksF+crGQ+jf61eI2WBASmQcP0xUDreoO6yW1
         7fV 
X-Gm-Message-State: AIVw112EyUoX7VnN+CplxW101Jw/aXXkqy4O8uZjWXGA667FRY5FFOGh
	ci5U1ox9Gn1KYia1
X-Received: by 10.25.168.83 with SMTP id r80mr235182lfe.16.1501434328834;
        Sun, 30 Jul 2017 10:05:28 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.28.128.145 with SMTP id b139ls459422wmd.20.gmail; Sun, 30 Jul
 2017 10:05:27 -0700 (PDT)
X-Received: by 10.28.125.195 with SMTP id y186mr10221068wmc.37.1501434327397;
        Sun, 30 Jul 2017 10:05:27 -0700 (PDT)
ARC-Seal: i=1; a=rsa-sha256; t=1501434327; cv=none;
        d=google.com; s=arc-20160816;
        b=S0TdQlH7ImYFSgDj7027awlQhmte+WGo2x4/BKp39tdIoYuwKuBsDianf9KvMUji73
         eyfNwfBPiSotrMyzC4sYS5w5ZUI1B8hJlMtWOQQDypjFzKnlY8sXXmFH3ZybcASYgU4m
         1TLKrBSxXheM+7soKHnmd6+3fj+W0oVMp131o7zBmWS0UIytmrZzqJm/jv+JKLjXY2jV
         +UKcxfIyIv8b83hbwpYlNFQZv5ikaatjyZwAxITY+djvlyOvGFBBMMOSanLWrm+OU4WR
         bRlcSh0U1hRujrodRlY6uVIPdlPbMdA6eARg6t/p0u7keUgXVcfpdTYRWscYx6T8WK9a
         oxLA==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
        h=content-transfer-encoding:to:subject:message-id:date:from
         :references:in-reply-to:mime-version:dkim-signature
         :arc-authentication-results;
        bh=FK2lEUfcWoucy67hq8StWk4JiohhX1IXKY5gck0CZL0=;
        b=NsAs6/9y1El2oZzqsG+BESisF8nuG7nb5XYkjONsRmteIr0/XDepdxbNFKYJnP10TF
         KN2+DUKRu0E7pkbcE6RSJ8PnCBl38NgAPrmIQXAO6XXzC+vr+50Y9eaQlQhrBEJheoFh
         27vDGiZN8zYyD7CTlNphn7cPbUgysdsPuq7DFfJK+MlFN1jwKoLaRRCLwcSHy7+xLwTL
         2ck6jqaZvssiAOpdLajEyMCd1y11a2xn2P8+AX4WhafBdacayUFp16UfCaSSsXhvgflv
         M/8t3qkf7whdXvGq0SfAU53Lvl3/UwG7iJ6/TN1cgwDEnY6qsSX1hCYIRDr31OOuANJ4
         /FJw==
ARC-Authentication-Results: i=1; mx.google.com;
       dkim=pass header.i=@gmail.com header.s=20161025 header.b=uWg1+rwi;
       spf=pass (google.com: domain of daniel.kruegler@gmail.com designates 2a00:1450:400c:c0c::236 as permitted sender) smtp.mailfrom=daniel.kruegler@gmail.com;
       dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com
Original-Received: from mail-wr0-x236.google.com (mail-wr0-x236.google.com. [2a00:1450:400c:c0c::236])
        by mx.google.com with ESMTPS id m192si15843825wma.224.2017.07.30.10.05.27
        for <std-proposals@isocpp.org>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Sun, 30 Jul 2017 10:05:27 -0700 (PDT)
Received-SPF: pass (google.com: domain of daniel.kruegler@gmail.com designates 2a00:1450:400c:c0c::236 as permitted sender) client-ip=2a00:1450:400c:c0c::236;
Original-Received: by mail-wr0-x236.google.com with SMTP id f21so114556836wrf.5
        for <std-proposals@isocpp.org>; Sun, 30 Jul 2017 10:05:27 -0700 (PDT)
X-Received: by 10.223.166.17 with SMTP id k17mr10591820wrc.243.1501434326934;
 Sun, 30 Jul 2017 10:05:26 -0700 (PDT)
Original-Received: by 10.28.40.69 with HTTP; Sun, 30 Jul 2017 10:05:26 -0700 (PDT)
In-Reply-To: <CAFk2RUaQ-BG4+y0N2GiEDsVNLBUsb2-_bmgid6=qcEt5N0e_Mw@mail.gmail.com>
X-Original-Sender: daniel.kruegler@gmail.com
X-Original-Authentication-Results: mx.google.com;       dkim=pass
 header.i=@gmail.com header.s=20161025 header.b=uWg1+rwi;       spf=pass
 (google.com: domain of daniel.kruegler@gmail.com designates
 2a00:1450:400c:c0c::236 as permitted sender) smtp.mailfrom=daniel.kruegler@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:33451
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/33451>

2017-07-30 18:58 GMT+02:00 Ville Voutilainen <ville.voutilainen@gmail.com>:
> On 30 July 2017 at 19:37, Daniel Kr=C3=BCgler <daniel.kruegler@gmail.com>=
 wrote:
>> 2017-07-30 18:34 GMT+02:00 Ville Voutilainen <ville.voutilainen@gmail.co=
m>:
>>> On 30 July 2017 at 19:20, Thiago Macieira <thiago@macieira.org> wrote:
>>>> On Sunday, 30 July 2017 04:50:41 PDT james.a.cooper@gmail.com wrote:
>>>>> C++ allows enums to have an underlying type specified. When serialisi=
ng
>>>>> enum values it's important to use the correct type.
>>>>> This proposal is to add a utility function that casts an enum type to=
 its
>>>>> underlying value. This would make it easier to handle
>>>>> enum types in function overloads for serialisation. For example:
>>>>>
>>>>> template <typename T>
>>>>> std::ostream& write(std::ostream& os, const T& v)
>>>>> {
>>>>>     os << std::underlying_cast(v);
>>>>>     return os;
>>>>> }
>>>>
>>>> Yes on the convenience, but "underlying_cast" is the wrong name becaus=
e this
>>>> does not look like a regular cast.
>>>>
>>>> Something like "std::underlying_value" might be better.
>>>
>>> Perhaps we should change std::underlying_type to be an identity type
>>> for non-enums.
>>
>> Not for all of them, please. The term underlying type exists also for
>> wchar_t, char16_t, and char32_t and is different from the identity
>> type.
>
>
> I'm not talking about any particular term, but the trait.

I do as well.

> It's
> ill-formed to use it for a non-enum type today.

I know.

> I suppose having it return a non-identity type for the types you
> mentioned would be remotely plausible.

I wanted to ensure that we did no unintentionally define it as
identity for non-enum types exactly due to the mentioned types for
which the trait is currently not defined but where the term underling
type has already a well-defined meaning.

- Daniel

--=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/CAGNvRgDH%3Deef%3DTWoXor1MedUw9xBzm3bgSZKqsREN_-=
qaxTC_w%40mail.gmail.com.

.
