220 33447 <2570492.NpxuI0RVu0@tjmaciei-mobl1> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Thiago Macieira <thiago@macieira.org>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Proposal: underlying_cast
Date: Sun, 30 Jul 2017 09:20:17 -0700
Lines: 29
Approved: news@gmane.org
Message-ID: <2570492.NpxuI0RVu0@tjmaciei-mobl1>
References: <6a2c32ed-99b5-4cc5-86a5-ee3cc07567a3@isocpp.org>
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 1501431628 19654 195.159.176.226 (30 Jul 2017 16:20:28 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Sun, 30 Jul 2017 16:20:28 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBCB4TK757YBRBRMO7DFQKGQEB7R5WSA@isocpp.org Sun Jul 30 18:20:21 2017
Return-path: <std-proposals+bncBCB4TK757YBRBRMO7DFQKGQEB7R5WSA@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-pf0-f200.google.com ([209.85.192.200])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBCB4TK757YBRBRMO7DFQKGQEB7R5WSA@isocpp.org>)
	id 1dbqx0-0004WW-28
	for gclcip-std-proposals@m.gmane.org; Sun, 30 Jul 2017 18:20:18 +0200
Original-Received: by mail-pf0-f200.google.com with SMTP id t25sf134456755pfg.15
        for <gclcip-std-proposals@m.gmane.org>; Sun, 30 Jul 2017 09:20:23 -0700 (PDT)
ARC-Seal: i=2; a=rsa-sha256; t=1501431623; cv=pass;
        d=google.com; s=arc-20160816;
        b=QRBx3evcD6YTE7Hxv144fXifqAfeVchWKZKMmVe0kbF3bTrZTkVQeONK7yf1pc5OTC
         iPMKq43uPDV3aIBWOmdOxizELGR2f9m/Xo/YFy0lvIiYb4rmhOOSSGGv/55Rg8F+N0W8
         TQCCcY+u6YtzIqQp34KrAGMMUSkLN5jHQcAPzJTxxtKviasfTgslJ5GyPuZpCrMWxerg
         mTkaSTXr+Kmn8DNRcgirSFkSfB5axCX8+RZEDEo+kKmpICQXDf+WrLNdltGbO5Lbw9o3
         dvVs8SXQj9UhhQefDhQPDEUtu8NIwhdE4OjdrtviFtDpeiMH3Z8aITx11XyvzZlTP0Zo
         JDhA==
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:mime-version:references
         :in-reply-to:message-id:date:subject:to:from
         :arc-authentication-results:arc-message-signature:dkim-signature
         :arc-authentication-results;
        bh=Ao4+t0iXjevQQyY+TFlk82ZgQuPEIitJUssuuTgDEug=;
        b=neVC15koMMh8pZ+MN0W84y8GGgftTtWsePAzIoUidgx1yDPlucE3SDWcY5pYWIJXT2
         lWy7JR6qti7WaJ3oCXIpiSqypg8DKnUycmEbqigkCWUBPB6P2av5uxEH7rZMuSUanyR5
         SktlWTFAs11lNVrCIsx9cFzTlr/3YgLP6h8m08O5+nZGHwPoqCu5lFg3j9RZErahY6X6
         K3/Zwh2uAyUAdTTYnLoYBqz/GUeYioBtkx2B3QmpLrSYxEW9YyT37DJ1Fjy+iydreh+f
         EBBx1zK1ilroerb6QQUR7gb8PTC2ZtGUitCi9Cw4kZPzOQpbzmY6x29EJ/EEvRZ9U77N
         knrA==
ARC-Authentication-Results: i=2; mx.google.com;
       spf=pass (google.com: domain of thiago@macieira.org designates 78.47.120.188 as permitted sender) smtp.mailfrom=thiago@macieira.org
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=from:to:subject:date:message-id:in-reply-to:references:mime-version
         :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=Ao4+t0iXjevQQyY+TFlk82ZgQuPEIitJUssuuTgDEug=;
        b=Upop7QskAv1C1maQxSibJwNJKJCS044XGgMA4hJkcQE7loydv5FOG3qoskYuZnB4fA
         nEMiUwqk0Wj5KeRr3ryPrThE6T78Rs2j8/OOmR4vZXOzOYszULVbMQV7BAJYLhJl5OR5
         3p7cuHljAtwEhPtep+0QmeKtmXJC5hv9vdNSRPREmsamDFBfuPIQxNjvbzLSFTkrXm56
         cMGzH53yMUfEBKfdF4sbYwLf7dojui7mq6iJKaz4+gBiTcD+JTz+pLFPmC1dX5WQHbFy
         jfHOe6KYuND5IHRBqhk/15LU74p3RlPb33rv+xRVlWONP6kUtlxoQcJXNWR4TU2UEDfh
         nrMg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to
         :references:mime-version: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=Ao4+t0iXjevQQyY+TFlk82ZgQuPEIitJUssuuTgDEug=;
        b=l8DD7xcUKFkPXaU7varPSOrfC2FmvRITJ3RmJbm4CSzN4TdEtionv29TutOyPeAn3b
         xm9qy2XrExxdZ7Hd8lr6usVKHRfxg81vF/wnx8hPNdmWPBVIdpHYw/ke7jBVIrTyeQLy
         7HBN14+1M2SRPPIda+rwZjhfDGpPWjDH6gMwM0NFEAvAaPJp0em0eKqvIBJmd7+PxDGj
         aczUyw0igDyELqkwn08nNtL/3R8Auopo4F4fy5boBt0nbFTf/8HaqqUtX2r2/jT1oeez
         xUDI74vk6TM1e16+fIMpUpTYUFSMm7C6/TvegyEC26kTUHY1c+T2/oUkH/YNWiA/rbJB
         GHBw==
X-Gm-Message-State: AIVw113AxN961g0p83ujIXru1fUKXopKou93aD4w6YHIekBfM3qkf1aW
	YGZ55z9m6N89M7wY
X-Received: by 10.99.147.75 with SMTP id w11mr10073229pgm.77.1501431623242;
        Sun, 30 Jul 2017 09:20:23 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.36.137.196 with SMTP id s187ls6663815itd.2.canary-gmail; Sun,
 30 Jul 2017 09:20:21 -0700 (PDT)
X-Received: by 10.36.46.19 with SMTP id i19mr15859912ita.124.1501431621587;
        Sun, 30 Jul 2017 09:20:21 -0700 (PDT)
ARC-Seal: i=1; a=rsa-sha256; t=1501431621; cv=none;
        d=google.com; s=arc-20160816;
        b=CBYMMkYdQlipivAv2PaDWWKIuqyIU+TqMoaEne5ZatXq1PPE4TBvsXlcU5NCePbYI3
         SMPA5MRoaoLDt1AqMhFlnkwzWFcwZnwAIdZOmkNvNKT3+D46xohgZBx8025fUv/4UoHN
         9n97nWVwxlCWwjwjvf56TTRxZhvizhdeKi2daJvbdWHYUwcSRJ2xlelEgdaxRJPHcnbQ
         cx1tYEl0Q8CEIQoMfGRsMOXao91fICKsHQWRwsgvCDKouamw4ZezVWkv44M9PptLJMQ4
         tRKlZ/Q+iW2j3PNxxixtrtpQzjqQCDrJH2/a1crXRVNJNy6TPxrbtd1DXf5Z/2WX8tHg
         rBWA==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
        h=content-transfer-encoding:mime-version:references:in-reply-to
         :message-id:date:subject:to:from:arc-authentication-results;
        bh=wHtMF5hmFgfs/0lCgFxxHXLQWCPtYPMG1AIHfA1SH0I=;
        b=uLz8SVEDumu8um9y+G5emM1ZGX/FvE4uYkpA45fwR1KGGzkcOMLWFlStC0aHth107z
         8MHX8S61X1oDbtVKKZ8r7He867O/JmksHEH5opvmoWmlc7GArWhbzBzkKxWfpzTu4+AP
         xoaq18Wi3+8BbCFCf20dKS1etKxQ8DSI6LTC51HKwXohHG+5xUPku1uMrgm+kQHrxi26
         n8JgPjCGql53RMAZglp0FPFeEUrdy/EBBQ+ycW/PaCMOSGIjiy06OqjLRJQpg8mqrJ3b
         sk/pI4hMHj6VS87mBAM4XQjo5afrTEo4lbtgciGQaq4BvrD3pjvuUoLQOLKQh5EZeaSX
         Km0A==
ARC-Authentication-Results: i=1; mx.google.com;
       spf=pass (google.com: domain of thiago@macieira.org designates 78.47.120.188 as permitted sender) smtp.mailfrom=thiago@macieira.org
Original-Received: from gondolin.macieira.info (gondolin.macieira.info. [78.47.120.188])
        by mx.google.com with ESMTP id s16si10291211ita.101.2017.07.30.09.20.21
        for <std-proposals@isocpp.org>;
        Sun, 30 Jul 2017 09:20:21 -0700 (PDT)
Received-SPF: pass (google.com: domain of thiago@macieira.org designates 78.47.120.188 as permitted sender) client-ip=78.47.120.188;
Original-Received: from tjmaciei-mobl1.localnet (unknown [IPv6:2601:1c0:4501:5f9f:fd1e:b479:f06b:403])
	by gondolin.macieira.info (Postfix) with ESMTPSA id C2B2F11B58A
	for <std-proposals@isocpp.org>; Sun, 30 Jul 2017 09:20:19 -0700 (PDT)
In-Reply-To: <6a2c32ed-99b5-4cc5-86a5-ee3cc07567a3@isocpp.org>
X-Original-Sender: thiago@macieira.org
X-Original-Authentication-Results: mx.google.com;       spf=pass (google.com:
 domain of thiago@macieira.org designates 78.47.120.188 as permitted sender) smtp.mailfrom=thiago@macieira.org
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:33447
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/33447>

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 serialising
> 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 because this 
does not look like a regular cast.

Something like "std::underlying_value" might be better.

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel Open Source Technology Center

-- 
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/2570492.NpxuI0RVu0%40tjmaciei-mobl1.

.
