Won’t a simple typecast work?
However – as a design notion, I really prefer to see explicit code which handles things like this, so that (a) I can plainly see that this is a comparison that the rest of the program is interested in, and (b) I have “just one place” at which to change the [entire …] program’s behavior if it needs to be changed.
“Okay, so this enum is ‘ordered.’” All of the enumeration values happen to correspond to integers that can be meaningfully compared with operators like
>, and the correct interpretation of that operator is, right now, identical to that of “the underlying integers.” Now, here comes Private SNAFU – a change, beyond your control (say in an outside API …) throws a monkey-wrench. Now you’re running all over the code doing search-and-replace or worse. (Hope you don’t miss a single one, because you’re now screwed if you do.)
I prefer to treat enums as fairly-abstract types … and, “not ordinal.” I prefer to put comparison and other operations into clearly-defined (even if “redundant”) pieces of code which document the behavior while providing a single point of change.