Closed johnstairs closed 1 year ago
This addresses a compilation error when using flags with a base type that is not int32.
int32
Note that the fix will mean that flags are no longer implicitly convertible to bool, meaning that checks like this will not compile:
bool
if (f & MyFlags::kB) { std::cout << "b is set" << std::endl; }
But unless you know that kB as exactly one bit set, the condition above is potentially incorrect and you should instead write:
kB
if (f.HasFlags(MyFlags::kB)) { std::cout << "b is set" << std::endl; }
or the expanded form:
if ((f & MyFlags::kB) == MyFlags::kB) { std::cout << "b is set" << std::endl; }
This addresses a compilation error when using flags with a base type that is not
int32
.Note that the fix will mean that flags are no longer implicitly convertible to
bool
, meaning that checks like this will not compile:But unless you know that
kB
as exactly one bit set, the condition above is potentially incorrect and you should instead write:or the expanded form: