fork download
  1. #include <iostream>
  2. #include <cstdint>
  3.  
  4. template <int n> class Int { };
  5. template <> class Int<8> { public: typedef int8_t Type; };
  6. template <> class Int<16> { public: typedef int16_t Type; };
  7. template <> class Int<32> { public: typedef int32_t Type; };
  8. template <> class Int<64> { public: typedef int64_t Type; };
  9.  
  10. int main()
  11. {
  12. Int<8>::Type a;
  13. Int<16>::Type b;
  14. Int<32>::Type c;
  15. Int<64>::Type d;
  16. std::cout << sizeof a << std::endl;
  17. std::cout << sizeof b << std::endl;
  18. std::cout << sizeof c << std::endl;
  19. std::cout << sizeof d << std::endl;
  20. }
  21.  
Success #stdin #stdout 0s 2828KB
stdin
Standard input is empty
stdout
1
2
4
8