220 40117 <67f2bf5e-14cf-487f-8d87-9171f49f2ffe@isocpp.org> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Chris Hallock <christopherhallock@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: enumerator duplicated value attribute
Date: Fri, 7 Sep 2018 13:13:34 -0700 (PDT)
Lines: 104
Approved: news@gmane.org
Message-ID: <67f2bf5e-14cf-487f-8d87-9171f49f2ffe@isocpp.org>
References: <CAFdMc-39pqfHATmWOA=iVNPmGDW0yqGh-jtqrxQPb9ALA=NK2A@mail.gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_444_2067409423.1536351214745"
X-Trace: blaine.gmane.org 1536351091 9094 195.159.176.226 (7 Sep 2018 20:11:31 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Fri, 7 Sep 2018 20:11:31 +0000 (UTC)
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBCHINCHEQEFBB35XZPOAKGQEK57AH5I@isocpp.org Fri Sep 07 22:11:27 2018
Return-path: <std-proposals+bncBCHINCHEQEFBB35XZPOAKGQEK57AH5I@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-yw1-f70.google.com ([209.85.161.70])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBCHINCHEQEFBB35XZPOAKGQEK57AH5I@isocpp.org>)
	id 1fyN6E-0002DE-Lg
	for gclcip-std-proposals@m.gmane.org; Fri, 07 Sep 2018 22:11:26 +0200
Original-Received: by mail-yw1-f70.google.com with SMTP id q141-v6sf9485369ywg.5
        for <gclcip-std-proposals@m.gmane.org>; Fri, 07 Sep 2018 13:13:37 -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
         :list-post:list-help:list-archive:list-subscribe:list-unsubscribe;
        bh=jT2o34xFFom882aiivs2FE6MWYcw4QD6236aJnGe+l0=;
        b=SJwamN6j9FegLoM7THWr/1BVMzJXNL7NlPp8WkZRGGL/70O78bZI607rOZNMRS3+tL
         2lH6GRDSoSdAzLPV984/9tHFRQdaa5BQtcfuazle6EkXFxqqwtZEn7GawmMbenLqefKR
         UoqBloBP/Ee30mVTG7cp1LwPWRUKSTMK2v/K30AnMDjHQJaLwOKMXgfZnNM0l6AxMw10
         Emu5mRsdFGLPFnCr4QZFVNi6dxtoqb3ZDwvAlKtD+DhXcoHcgIaAqJ8iE5RA0uzKPdnp
         RmSSGb07P6+xJCsydaaxU1BZsceyA+vv4Nz3eV8fsMdnPAHvwyGINFAstIcvQJAIlJnt
         Ibpw==
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
         :list-post:list-help:list-archive:list-subscribe:list-unsubscribe;
        bh=jT2o34xFFom882aiivs2FE6MWYcw4QD6236aJnGe+l0=;
        b=kfYxfwjFokRPBgZ2MELeNvgHEPSKICRIq0ZeGBk/AjUFN5dFMc2JpomjiTB7nyy9eL
         zDsjBERLGQx7qxcEs0VRILuS9lKSs+dCFymNCwHBKcW5ChmVAvFS6KXp1zEY8xK4aNNC
         pbbrKZP/iu5MpJ96eEUxg9AVAUAq0dOyHJBs3gFZtqcTfI8n7Dj/OKqy4Z0cSkFXSSMt
         P40WW/HrLWOgWiBgsVcxAwXZAR/ieP5WakYk+L+WNwFIJDHVBdgtyteWxIXNqP6jewQj
         Dx/TJRtsmQiPtNBsli4Wdbsb+iYLuut/IxM4x9iuNuGoc0yydMwPriLXpXip/OIEjZAV
         /sHg==
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=jT2o34xFFom882aiivs2FE6MWYcw4QD6236aJnGe+l0=;
        b=ru0g6WO9KrcXeCAHgnZqNStMyR2WAG5UIZVj8q0w8Sahp5ehQ/tkJ1eJnS0QCLXr31
         f0Pz3yFSFvvV1hkPB/J+b67lXUtrwdoH4z9WB0p3HxfyTqxB3lgPje4qUWWqIpcfJoKA
         EKqHATbiGKoQcSApDD+PPwhbt+83aYRXgM2vdGLAfkPx5sJw1CCYK4nhv6/JMn9VADmW
         M7Xze8b/TQbKDrbrNuwMyQluxGvuJ3GOlN2LVVwKJtRORcJyvr6NSovC59rcsGKjQp12
         ++F4rYBfKTaYry8uxunalywAy/qnrXS1ISDKzVky+3imvF6nwgHhalCnYvtMticyxJ89
         D95A==
X-Gm-Message-State: APzg51CbZf0MTuJ5icDVNTrhipvRiI+X5ZvqGJ3Li4FmZQmy+bP35Dxd
	Kd0IoZx+Ie4yCb49QMcFskUNdQ==
X-Google-Smtp-Source: ANB0VdYoigPLykhAT8CyC1Z8wJewv/CergJMyhemg98/5sFM3nLXvtPZJnoOsSIKn0wj+zVW5eEhGA==
X-Received: by 2002:a81:3b07:: with SMTP id i7-v6mr2512869ywa.228.1536351216692;
        Fri, 07 Sep 2018 13:13:36 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 2002:a0d:ec93:: with SMTP id v141-v6ls842897ywe.42.gmail; Fri, 07
 Sep 2018 13:13:35 -0700 (PDT)
X-Received: by 2002:a81:6e04:: with SMTP id j4-v6mr96404ywc.6.1536351215315;
        Fri, 07 Sep 2018 13:13:35 -0700 (PDT)
In-Reply-To: <CAFdMc-39pqfHATmWOA=iVNPmGDW0yqGh-jtqrxQPb9ALA=NK2A@mail.gmail.com>
X-Original-Sender: christopherhallock@gmail.com
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <std-proposals.isocpp.org>
X-Spam-Checked-In-Group: 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:40117
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/40117>

------=_Part_444_2067409423.1536351214745
Content-Type: multipart/alternative; 
	boundary="----=_Part_445_1561369125.1536351214745"

------=_Part_445_1561369125.1536351214745
Content-Type: text/plain; charset="UTF-8"



On Friday, September 7, 2018 at 2:55:57 PM UTC-4, Daniel Gutson wrote:
>
> Hi,
>
>    sometimes is important to prevent duplication of enumerators in the 
> enumerations. That's why some compilers such as clang has the 
> -Wduplicate-enum.
> However there are cases such as ranges within enums, where enumerators 
> define a category and then are followed by the first element of the 
> category, with the same value.
>
> enum Ranges
> {
>     CategoryX = 100,
>        X1 = CategoryX,
>        X2,
>        X3
>      CategoryY = 200
>        // ...
> };
>
> In order to allow such cases coexist with the useful diagnostic, I propose 
> adding an enumerator attribute, such as [[allow_duplicate]]
>
> enum Ranges
> {
>     CategoryX = 100 [[allow_duplicate]],
>        X1 = CategoryX,
>        X2,
>        X3
>      CategoryY = 200 [[allow_duplicate]]
>        // ...
> };
>
> This way, we can have the diagnostic and also explicit the intention that 
> in those cases it is OK to have a repeated value.
>

That warning triggers only on *implicit* duplicates, so you're all good.

-- 
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/67f2bf5e-14cf-487f-8d87-9171f49f2ffe%40isocpp.org.

------=_Part_445_1561369125.1536351214745
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><br>On Friday, September 7, 2018 at 2:55:57 PM UTC-4, =
Daniel Gutson wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;ma=
rgin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=
=3D"ltr">Hi,<div><br></div><div>=C2=A0 =C2=A0sometimes is important to prev=
ent duplication of enumerators in the enumerations. That&#39;s why some com=
pilers such as clang has the -Wduplicate-enum.</div><div>However there are =
cases such as ranges within enums, where enumerators define a category and =
then are followed by the first element of the category, with the same value=
..</div><div><br></div><div>enum Ranges</div><div>{</div><div>=C2=A0 =C2=A0 =
CategoryX =3D 100,</div><div>=C2=A0 =C2=A0 =C2=A0 =C2=A0X1 =3D CategoryX,</=
div><div>=C2=A0 =C2=A0 =C2=A0 =C2=A0X2,</div><div>=C2=A0 =C2=A0 =C2=A0 =C2=
=A0X3</div><div>=C2=A0 =C2=A0 =C2=A0CategoryY =3D 200</div><div>=C2=A0 =C2=
=A0 =C2=A0 =C2=A0// ...</div><div>};</div><div><br></div><div>In order to a=
llow such cases coexist with the useful diagnostic, I propose adding an enu=
merator attribute, such as [[allow_duplicate]]</div><div><br></div><div><di=
v>enum Ranges</div><div>{</div><div>=C2=A0 =C2=A0 CategoryX =3D 100 [[allow=
_duplicate]],</div><div>=C2=A0 =C2=A0 =C2=A0 =C2=A0X1 =3D CategoryX,</div><=
div>=C2=A0 =C2=A0 =C2=A0 =C2=A0X2,</div><div>=C2=A0 =C2=A0 =C2=A0 =C2=A0X3<=
/div><div>=C2=A0 =C2=A0 =C2=A0CategoryY =3D 200 [[allow_duplicate]]</div><d=
iv>=C2=A0 =C2=A0 =C2=A0 =C2=A0// ...</div><div>};</div><div><br></div><div>=
This way, we can have the diagnostic and also explicit the intention that i=
n those cases it is OK to have a repeated value.</div></div></div></blockqu=
ote><br><div>That warning triggers only on <i>implicit</i> duplicates, so y=
ou&#39;re all good.<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/67f2bf5e-14cf-487f-8d87-9171f49f2ffe%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/67f2bf5e-14cf-487f-8d87-9171f49f2ffe=
%40isocpp.org</a>.<br />

------=_Part_445_1561369125.1536351214745--

------=_Part_444_2067409423.1536351214745--

.
