C++ enum flags vs bitset
What are pros/cons of usage bitsets over enum flags? namespace Flag { enum State { Read = 1 << 0, Write = 1 << 1, Binary = 1 << 2, }; } namespace Plain { enum State { Read, Write, Binary, Count }; } int main() { { unsigned int state = Flag::Read | Flag::Binary; std::cout << state << std::endl; state |= Flag::Write; state &= ~(Flag::Read | Flag::Binary); std::cout << state << std::endl; } { std::bitset<Plain::Count> state; state.set(Plain::Read); state.set(Plain::Binary); std::cout << state.to_ulong() << std::endl; state.flip(); std::cout << state.to_ulong() << std::endl; } return 0; } As I can