fork download
  1. #include <iostream>
  2. #include <type_traits>
  3.  
  4. using namespace std;
  5.  
  6. enum type_t {
  7. integer,
  8. other
  9. };
  10.  
  11. template<typename T>
  12. struct get_type
  13. {
  14. static constexpr type_t type = is_integral<T>::value ? integer : other;
  15. };
  16.  
  17. int main(int argc, char * argv[])
  18. {
  19. cout << get_type<long>::type << endl;
  20. cout << get_type<double>::type << endl;
  21. }
  22.  
Success #stdin #stdout 0.01s 5392KB
stdin
Standard input is empty
stdout
0
1