Question

why aren't instances of strongly typed C++0x enumerations comparable to each other?


Update: They are comparable in gcc 4.6; I'm not sure if it worked in gcc 4.4.

Was it helpful?

Solution

If you use strongly typed enumerations, it's like making your enum a realy type, a class. Then it follows the same rules as for classes.

Instances of different classes can't be compared to each other by default. You have to define a comparison function (or member function) to make them comparable.

Therefore making an enumeration strongly typed makes it follows this very same rule.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top