fork(1) download
  1. #include <stdio.h>
  2.  
  3. struct Foo {
  4. enum { VAL_A = 0, VAL_B = 1, VAL_C = 2 };
  5. };
  6.  
  7. struct Bar {
  8. enum { VAL_A = 10, VAL_B = 11, VAL_C = 12 };
  9. };
  10.  
  11. template<typename T>
  12. void TestSwitch(int op)
  13. {
  14. printf("%u: ", op);
  15. switch (op) {
  16. case T::VAL_A: printf("aaa\n"); break;
  17. case T::VAL_B: printf("bbb\n"); break;
  18. case T::VAL_C: printf("ccc\n"); break;
  19. default: break;
  20. }
  21. }
  22.  
  23. int main() {
  24. TestSwitch<Foo>(0);
  25. TestSwitch<Bar>(12);
  26. }
  27.  
Success #stdin #stdout 0s 3468KB
stdin
Standard input is empty
stdout
0: aaa
12: ccc