fork download
  1. #include <iostream>
  2. using namespace std;
  3. enum class RuleSeverityEnum
  4. {
  5. FATAL,
  6. ERROR,
  7. WARNING,
  8. INFO,
  9. LAST
  10. };
  11. int main() {
  12. RuleSeverityEnum old_severity = RuleSeverityEnum::ERROR;
  13. RuleSeverityEnum new_severity = RuleSeverityEnum::FATAL;
  14. int old_sev = (int)old_severity;
  15. int new_sev = (int)new_severity;
  16. bool is_new_severity_illegal = ( old_sev < new_sev );
  17.  
  18. if(is_new_severity_illegal && !old_sev)
  19. cout<<"Can't be downgraded\n";
  20. else
  21. cout<<"can be downgraded\n";
  22.  
  23. return 0;
  24. }
Success #stdin #stdout 0s 15232KB
stdin
Standard input is empty
stdout
can be downgraded