This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of Open status.
enum class
bitmask typesSection: 16.3.3.3.3 [bitmask.types] Status: Open Submitter: Geoffrey Romer Opened: 2018-03-26 Last modified: 2020-09-06
Priority: 3
View other active issues in [bitmask.types].
View all other issues in [bitmask.types].
View all issues with Open status.
Discussion:
[bitmask.types] specifies the semantics of a bitmask type in terms of an "exposition only" enum
definition,
together with some constants and overloads. Notably, it is depicted as an unscoped enum, which implies among other
things that it is implicitly convertible to int_type
. At least some sources treat that as normative (as
of this writing, cppreference.com's documentation for
BitmaskType
says the expression
(X & Y) != 0
is guaranteed to be well-formed), and it's hard to argue that they're wrong on the basis
of the existing wording.
[2018-04-23 Priority set to 2 after discussion on the reflector.]
[2018-08-23 Batavia Issues processing]
N3110 also touches on this.
Nico to survey the enums in the library and report back on which ones should be class.
[2019 Cologne Wednesday night]
Changing existing enums to class enums is an ABI break on some platforms; current wording does not require the use of enums. See N3110.
Daniel to provide requirements tables, Jonathan to assist. Reduce priority to 3
Proposed resolution:
This wording is relative to N4727.
Edit 16.3.3.3.3 [bitmask.types] as indicated:
-2- The bitmask type
bitmask
can be written:// For exposition only. // int_type is an integral type capable of representing all values of the bitmask type.enumE bitmask : int_type { V0 = 1 << 0, V1 = 1 << 1, V2 = 1 << 2, V3 = 1 << 3, ..... }; […]-3- Here,
E
may represent eitherenum
orenum class
(the choice is implementation-defined unless otherwise specified), and the namesC0
,C1
, etc. represent bitmask elements for this particular bitmask type. The zero valuebitmask{}
is used to represent an empty bitmask, in which no bitmask elements are set. Allsuchbitmask elements have distinct, nonzero values such that, for any pairCi
andCj
wherei ≠ j
,Ci & Ci
is nonzero andCi & Cj
is zero.Additionally, the value0
is used to represent an empty bitmask, in which no bitmask elements are set.