I may be wrong, but it looks like you might be confusing the concept that people call "bitfields" (packing information using bitops) with the actual language feature called "bitfields." I was talking about the language feature, which I've never seen used outside of very low-level code like the Linux kernel.
The code I posted is the language feature, which allows you to specify bit widths for members of a struct, usually so you can map it directly to hardware bits. You can also do empty padding bits, I think it looks like this:
struct SomeBitfield
{
unsigned first_bit : 1;
unsigned second_bit : 1;
unsigned : 4; // 4 bits of padding.
unsigned third_bit : 1
};
This is the sort of thing I was referring to, not the general practice of packing flags into a single variable. Stroustrup barely mentions these in his book, and in the K&R C book they get less than a page of treatment. It's one of the few language features I've never had a use for.
Now I believe you could rewrite your EntityFlag like so:
struct EntityFlags
{
bool alive : 1;
bool frozen : 1;
bool newborn : 1;
bool hidden : 1;
};
void do_something(EntityFlags flags)
{
if (flags.newborn)
{
//stuff
}
}
This saves you the time of writing the bitops, the compiler will do it all for you. I'm not sure how wise this is though, the little that I've seen about bitfields seems to imply that there is a lot of implementation dependent magic involved, so I'm not sure what utility they would have outside of the most low-level of code.