fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. template<typename T> // primary template
  5. struct is_int : std::false_type
  6. {};
  7.  
  8. template<> // explicit specialization for T = int
  9. struct is_int<int> : std::true_type
  10. {};
  11.  
  12. int main() {
  13. std::cout << is_int<char>::value << std::endl; // prints 0 (false)
  14. std::cout << is_int<int>::value << std::endl; // prints 1 (true)
  15. return 0;
  16. }
Success #stdin #stdout 0.01s 5292KB
stdin
Standard input is empty
stdout
0
1