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.
Comments?
Daniel.
--
Who’s got the sweetest disposition?
One guess, that’s who?
Who’d 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?