fork(15) download
  1. #include <iostream>
  2. enum COLOR
  3. {
  4. Blue,
  5. Red,
  6. Green,
  7. Purple,
  8. Last,
  9. First=Blue,
  10. };
  11.  
  12. inline COLOR operator++( COLOR& x ) { return x = (COLOR)(std::underlying_type<COLOR>::type(x) + 1); }
  13. COLOR operator*(COLOR c) {return c;}
  14. COLOR begin(COLOR r) {return First;}
  15. COLOR end(COLOR r) {return Last;}
  16.  
  17.  
  18. int main() {
  19. for(auto c : COLOR()) {
  20. std::cout << c << '\n';
  21. }
  22. return 0;
  23. }
Success #stdin #stdout 0s 2852KB
stdin
Standard input is empty
stdout
0
1
2
3