#Enum class doesn't convert to u32 properly

12 messages · Page 1 of 1 (latest)

hoary spruce
#

Hey. I defined an enum class like this:

enum class BitEnum : quint32 { ..., SIZE };

But it looks like the conversion from BitEnum to quint32 still doesn't happen here when I declare this bitset:

std::bitset<BitEnum::SIZE> bits;

Am I missing something here? Is there a way to do this without static_cast?

crude sentinelBOT
#

When your question is answered use !solved or the button below to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

vale mesa
hoary spruce
#

There are over 1000 constant values that need to be +1 from one another, so I think I need an enum yes

vale mesa
hoary spruce
#

But enummay conflict with other enums that have the same names, right?

vale mesa
#

Yes

#

Im just telling you that, scoped enum donot automatically convert

#

I'd just recommend casting but if for some reason you want implicit conversion you can wrap an unscoped enum into namespace

hoary spruce
#

Oh this is smart. I don't think I'll do that but I'll definitely remember the trick

#

Thank you!

#

!solved