220 40116 <CAFdMc-39pqfHATmWOA=iVNPmGDW0yqGh-jtqrxQPb9ALA=NK2A@mail.gmail.com> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Daniel Gutson <danielgutson@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: enumerator duplicated value attribute
Date: Fri, 7 Sep 2018 15:55:42 -0300
Lines: 114
Approved: news@gmane.org
Message-ID: <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/alternative; boundary="000000000000a28a7b05754c8e58"
X-Trace: blaine.gmane.org 1536346431 6000 195.159.176.226 (7 Sep 2018 18:53:51 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Fri, 7 Sep 2018 18:53:51 +0000 (UTC)
To: std-proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBDE3NBMV6UFBBO4TZPOAKGQELGWUFFY@isocpp.org Fri Sep 07 20:53:46 2018
Return-path: <std-proposals+bncBDE3NBMV6UFBBO4TZPOAKGQELGWUFFY@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-lf1-f72.google.com ([209.85.167.72])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBDE3NBMV6UFBBO4TZPOAKGQELGWUFFY@isocpp.org>)
	id 1fyLt4-0001TD-OQ
	for gclcip-std-proposals@m.gmane.org; Fri, 07 Sep 2018 20:53:46 +0200
Original-Received: by mail-lf1-f72.google.com with SMTP id o4-v6sf2850675lfg.11
        for <gclcip-std-proposals@m.gmane.org>; Fri, 07 Sep 2018 11:55:57 -0700 (PDT)
ARC-Seal: i=2; a=rsa-sha256; t=1536346557; cv=pass;
        d=google.com; s=arc-20160816;
        b=k10gLSWJuyzUMR4I0cmmTEz9X7KnHX7yrqD9yfLsio0sE8IZtwtARz4N7DguAKV9hx
         ysparvxQ02WkW7ajEYvlZhBv8V0GEjune6OMqXjk3h8Z6K7AB5Rbwx9Iriclbp/b1/HZ
         Uo7ozduYaD+vA5zP0YX4P6dfsSkbr+nS2LOiQ266aQI4eLUENvhMGsXXA2Id/vhuG/LO
         +G4f7kj4kApY/EhzlUCh0VlJfqaGIWKtvyA679J9g3EJvxwU5He0gZT7gKaFMsWrtuHV
         TVztLYrcTefxRnlkZEm8OAqKsrrUlEao1S+yszV4ZiV5jmoXqMOoyyTbOhgWgSQwFg4m
         6O4g==
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:to:subject:message-id:date
         :from:mime-version:dkim-signature;
        bh=weJo2J9XOyoUh5NIlhv4OsFMeqhVw74fSPlC/gfib+I=;
        b=v5Lxz+ZZ7PEIdVB3klQWuhWzu2PLUAsPISrPKKUjuTHD1R36O6CF64C+2l7d47hGhU
         tOaOKG2CacvV9r+0hnF1S5S6K/RLQGa6zWNqERUzneEU21EOEG9PCm5Hr1mhFmvS4nHK
         +yDQ3I0fi/73j2rTTzV7pKrBoTIelQvh5IttWc+3GJ3gpLHcrF64xWsXjIR9UsAYJX+j
         bpYLy/MOKvE818zVJ+xWbHJgVBpfuWGE0yMwjvQFacvY7bF8hr/RjcQIJ0cuTV1DRh0p
         0XmM92fSZNfCAO5W+OIDumjbRuAM9YheEbQ1A13cWq/LJUL9XU3ox3z80Mv1fbCmZJmk
         KCMQ==
ARC-Authentication-Results: i=2; mx.google.com;
       dkim=pass header.i=@gmail.com header.s=20161025 header.b=lLffIGD2;
       spf=pass (google.com: domain of danielgutson@gmail.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=danielgutson@gmail.com;
       dmarc=pass (p=NONE sp=QUARANTINE 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:from:date:message-id:subject:to: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=weJo2J9XOyoUh5NIlhv4OsFMeqhVw74fSPlC/gfib+I=;
        b=j4i1lJDWcMzIeGf0TE9ttS2OKqhXswSbmE8CJGDvj7nfgR+Cb9ddat74PltWVJoabm
         1y7H8evnbdYK0rtcMvzHUx/YjAsMcnkeXn2qBKdRd339LCDc1uiWHlbVsuqH7EBH07Rw
         6CbvVp+m+B1dwUERLSq99qlSQp/NUj8A7cSwU7LqD2VPOeTG7089PPyeJe9Sxf8GKJyt
         HAK8v32JD1coZhODfk/9t2RUVt9VsQIHs+I0Hu4eDXJ10tKdrA1cvZRiHx5DJr5okTeE
         Yvx2hgQd76rFcnY6JCI4wbkOzeYlF08e2S+NI6RcbroFS5yaIK3+wtuGIFQxlEbS/LG0
         0YZg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:mime-version:from:date:message-id:subject:to
         :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=weJo2J9XOyoUh5NIlhv4OsFMeqhVw74fSPlC/gfib+I=;
        b=sNhF3vxd9B47AWW7Eqs8CiQZfj3Oedbg7sAErGH5Z4x0G5LoM4hfExPnXUDlK5NkbE
         2ik1LR/1yNzuwySov2TaTaTZgBeMlO9se53C8TfsTr0coZEM5QUk8M1l8VfVJrtaie9M
         eFwWfbYmXYbo7YJKrbKa2e8k8VwByvDxO4oI8qnYJLDpNgHww6Vxg5yDGqg33xHmLu0X
         NM6PmAPoLRBr5Z3XlArSTITwDTii1n2loKiVhuzfdNXqRfuk9DjHxLThw2XYIaahcfvf
         8i0C12BhIuw2qPBlZZljWlBiK1w6UWYK6p02LHGYysneGbusfvHbOzn5iJvwAmIwI7+J
         1rkA==
X-Gm-Message-State: APzg51C3MDPX4GRrOP4iUhrHXhz9Ysiz3vYrBSU1+5df+0jvPRm0ePxM
	ICz6ftj3uFnkQlsxWxSkTEXqcg==
X-Google-Smtp-Source: ANB0Vdbv5VKrBMI+/BLYsvAxePRWHyePPsT5KClYYWsq0lHf1q+2dpfF60jV9mWuZ2cxf9T1KzPEuQ==
X-Received: by 2002:a19:1298:: with SMTP id 24-v6mr229523lfs.16.1536346556963;
        Fri, 07 Sep 2018 11:55:56 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 2002:a2e:7605:: with SMTP id r5-v6ls913776ljc.13.gmail; Fri, 07
 Sep 2018 11:55:55 -0700 (PDT)
X-Received: by 2002:a2e:240c:: with SMTP id k12-v6mr2283911ljk.135.1536346555131;
        Fri, 07 Sep 2018 11:55:55 -0700 (PDT)
ARC-Seal: i=1; a=rsa-sha256; t=1536346555; cv=none;
        d=google.com; s=arc-20160816;
        b=FRni9ZAKUoRj7LgFPTSegAtGa1DGIXHll9WtdN/K1P9m30tjBaKOp2ies2l/4fKgj8
         /POEIn7mFQe7+uMIHmaM7WJiHwHZCjoJ4qmhBdZBzTOjffs7boc1279vV1rjyRDjQnRP
         3RQZViqQFDi+GxZM07UJJHe00dJYPBUsEPd+6gOtL8e5IkJqSzh0ylPjXIFA1sVurGVv
         1NyaCD/+eBsMMpf2+uSJgW9cwp6dyhkB9btFdAqVZGHukThX7f4+Rn2QrY1qv/Y0/KEQ
         J8vbLj64bH3Q6MmanHBXsihD1dr0pFGJ0jvyUhqc5rh3Pchn9gVdiNHNGeaZ81RRYKLp
         bKhg==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
        h=to:subject:message-id:date:from:mime-version:dkim-signature;
        bh=NJ5mJH/PyHcfO3u9MQkik9jRd6bTl9Hy4YQ3aPiwOHI=;
        b=FyQ4CdrKn/NzbyFpJxWLny8UIuzUntc6GjzAesN+fj5DmFW/aCa4PgIE5k17yQnzbE
         irTgGTQG8+FT6b43ZRwaN84enWxmGiZ7wrYOQLoX9KWgpmqEeB9tlbZpJ03LizNOj5uR
         mw2JyPllY6KFjAFW+T5JqwVgWEs1VY8W+s7rezOopEiHJriDKkyTEriJRROtlzxbpgMI
         mrYTmeAxLJ9xF8Q91wtDMbzKqaw2u+HshSJdPfHehKPJ9ZrpIyVLxffpH9m4LmKhIwrs
         SWCbjl8m7kmv6B97QqAMGRUKyaPIpym49bE12s+4/jaXCQNVHsesgtRDqYFiKcQDx12Z
         YW8Q==
ARC-Authentication-Results: i=1; mx.google.com;
       dkim=pass header.i=@gmail.com header.s=20161025 header.b=lLffIGD2;
       spf=pass (google.com: domain of danielgutson@gmail.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=danielgutson@gmail.com;
       dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com
Original-Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41])
        by mx.google.com with SMTPS id p64-v6sor4785575ljp.39.2018.09.07.11.55.55
        for <std-proposals@isocpp.org>
        (Google Transport Security);
        Fri, 07 Sep 2018 11:55:55 -0700 (PDT)
Received-SPF: pass (google.com: domain of danielgutson@gmail.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41;
X-Received: by 2002:a2e:870b:: with SMTP id m11-v6mr6205861lji.2.1536346554526;
 Fri, 07 Sep 2018 11:55:54 -0700 (PDT)
X-Original-Sender: danielgutson@gmail.com
X-Original-Authentication-Results: mx.google.com;       dkim=pass
 header.i=@gmail.com header.s=20161025 header.b=lLffIGD2;       spf=pass
 (google.com: domain of danielgutson@gmail.com designates 209.85.220.41 as
 permitted sender) smtp.mailfrom=danielgutson@gmail.com;       dmarc=pass
 (p=NONE sp=QUARANTINE 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-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:40116
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/40116>

--000000000000a28a7b05754c8e58
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

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 =3D 100,
       X1 =3D CategoryX,
       X2,
       X3
     CategoryY =3D 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 =3D 100 [[allow_duplicate]],
       X1 =3D CategoryX,
       X2,
       X3
     CategoryY =3D 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.

Comments?

    Daniel.



--=20
Who=E2=80=99s got the sweetest disposition?
One guess, that=E2=80=99s who?
Who=E2=80=99d never, ever start an argument?
Who never shows a bit of temperament?
Who's never wrong but always right?
Who'd never dream of starting a fight?
Who get stuck with all the bad luck?

--=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/CAFdMc-39pqfHATmWOA%3DiVNPmGDW0yqGh-jtqrxQPb9ALA=
%3DNK2A%40mail.gmail.com.

--000000000000a28a7b05754c8e58
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Hi,<div><br></div><div>=C2=A0 =C2=A0sometimes is important=
 to prevent duplication of enumerators in the enumerations. That&#39;s why =
some compilers such as clang has the -Wduplicate-enum.</div><div>However th=
ere are cases such as ranges within enums, where enumerators define a categ=
ory and then are followed by the first element of the category, with the sa=
me 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 Cate=
goryX,</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 ord=
er to allow such cases coexist with the useful diagnostic, I propose adding=
 an enumerator attribute, such as [[allow_duplicate]]</div><div><br></div><=
div><div>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><div>=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 intenti=
on that in those cases it is OK to have a repeated value.</div><div><br></d=
iv><div>Comments?</div><div><br></div><div>=C2=A0 =C2=A0 Daniel.</div><br c=
lass=3D"gmail-Apple-interchange-newline"></div><div><br clear=3D"all"><div>=
<br></div>-- <br><div dir=3D"ltr" class=3D"gmail_signature" data-smartmail=
=3D"gmail_signature">Who=E2=80=99s got the sweetest disposition?<br>One gue=
ss, that=E2=80=99s who?<br>Who=E2=80=99d never, ever start an argument?<br>=
Who never shows a bit of temperament?<br>Who&#39;s never wrong but always r=
ight?<br>Who&#39;d never dream of starting a fight?<br>Who get stuck with a=
ll the bad luck? </div></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/CAFdMc-39pqfHATmWOA%3DiVNPmGDW0yqGh-j=
tqrxQPb9ALA%3DNK2A%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter"=
>https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAFdMc-39pqfH=
ATmWOA%3DiVNPmGDW0yqGh-jtqrxQPb9ALA%3DNK2A%40mail.gmail.com</a>.<br />

--000000000000a28a7b05754c8e58--

.
