There are a few good arguments for using strongly typed enums instead of enumns. However, the convertibility to int offered besides its unwanted risks some nice use cases. in my case, mostly throwing it into a stringstream for logging and comparison.
enum RiskLevel { None, Warn, Low, High, Critical };
void logStuff( RiskLevel rl ) {
stringstream ss;
ss << rl;
LOG(s);
}
void compareEnum( RiskLevel rl ) {
if ( rl > RiskLevel::Low ) {
...
}
}
I do miss these features of the old enums and I am probably not the only one. What are good ways to use strongly typed enums and still easily log them and compare them?