fork download
  1. #include <iostream>
  2.  
  3. enum MyValue
  4. {
  5. Unk,
  6. A,
  7. B
  8. };
  9.  
  10. template<typename T>
  11. struct get_value
  12. {
  13. static constexpr MyValue value = MyValue::Unk;
  14. };
  15.  
  16. template<>
  17. struct get_value<int>
  18. {
  19. static constexpr MyValue value = MyValue::A;
  20. };
  21.  
  22. template<>
  23. struct get_value<double>
  24. {
  25. static constexpr MyValue value = MyValue::B;
  26. };
  27.  
  28. int main()
  29. {
  30. std::cout << get_value<char>::value << std::endl;
  31. std::cout << get_value<int>::value << std::endl;
  32. std::cout << get_value<double>::value << std::endl;
  33. }
Success #stdin #stdout 0s 3468KB
stdin
Standard input is empty
stdout
0
1
2