Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

strongly typed C++0x enumeration comparison

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.

like image 712
Neil G Avatar asked Jun 13 '10 00:06

Neil G


1 Answers

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.

like image 177
Klaim Avatar answered Oct 14 '22 13:10

Klaim