Re:Type-safe Bitmasks in C++
by nice_byte on Wednesday June 13, 2018 @05:14PM
(#17307001)
That had been brought up elsewhere. Let me just copy-paste my response:
"I think enums allow a bit more flexibility. For example, if you need to store a piece of data that indicates which option to set, it's easier to do with an enum (can't store the "name" of the bitfield, and you're not permitted to take its address or offset either IIRC).
I also like the 'Option1 | Option2 | ... ' syntax for creating bitmasks on the fly (not sure how you'd achieve that with bitfields)"
"I think enums allow a bit more flexibility. For example, if you need to store a piece of data that indicates which option to set, it's easier to do with an enum (can't store the "name" of the bitfield, and you're not permitted to take its address or offset either IIRC). I also like the 'Option1 | Option2 | ... ' syntax for creating bitmasks on the fly (not sure how you'd achieve that with bitfields)"