News for hackers. Stuff that matters.
Re:Type-safe Bitmasks in C++ by omgtehlion on Wednesday June 13, 2018 @07:03AM (#17301973)
This is all good and nice.

But in my opinion it violates principle of least surprise: when I encounter any enum, am I able to OR two values? These do not seem like flags, is this correct usage?

When a function expects bitmask<T>, I should know that T is just flag positions. But when I do not have some API point, only enum, how am I supposed to know that?

Plus, in case of interop with other languages, even with C, I will have Button::B == 2 in CPP, and BUTTON_B == 4 in C (or Button.B == 4 in Java). This of course adds to confusion...

There are no comments on this comment yet.