The members of enum
classes are not meant to convert to int
implicitly or vice versa. You can either make sure that your bitmask type is converted to int
or use the zero value of the enum
class. I'd think the latter is preferable:
(std::launch::async & std::launch::async) != std::launch()
(I have also added parenthesis around the bitwise and
operation since it has higher precedence than the comparison and it doesn't really make much sense to bitwise and
a Boolean value with a bitmask type).
The easiest way to see this is 7.2 [enum.dcl] paragraph 9:
... Note that this implicit enum to int conversion is not provided for a scoped enumeration: ...
This is, however, within a non-normative Example. Tracking the rules for scoped rules in the standard may require ruling out all the cases where conversions are allowed and currently don't quite fancy this exercise.