Closed Bug 1217241 Opened 10 years ago Closed 10 years ago

Add utils to define type-safe bit-flags

Categories

(Core :: MFBT, defect)

defect
Not set
normal

Tracking

()

RESOLVED INVALID
Tracking Status
firefox44 --- affected

People

(Reporter: xidorn, Unassigned)

Details

There are bit-flags all around our codebase. However, most of them use uint32_t as the type, which is not quite type-safe. If there are two different sets of flags use the same bits, you may mix them by mistake while compilers have no way to detect that. We should probably provide an easy way to define type-safe bit-flags, and use it in new code. With some investigation, it seems the easiest way to do so is using "enum class" for that, and then use a macro to define the full set of operators for it.
Doesn't mfbt/TypedEnumBits.h do this already?
Oh, yes, it seems so. Not sure how I ignored that.
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.