fork download
  1. #include <cstdint>
  2. #include <cstddef>
  3.  
  4. typedef uintmax_t FullInt;
  5.  
  6. template <size_t N>
  7. struct UInt;
  8.  
  9. template <>
  10. struct UInt<1> { typedef uint8_t type; };
  11.  
  12. template <>
  13. struct UInt<2> { typedef uint16_t type; };
  14.  
  15. template <>
  16. struct UInt<4> { typedef uint32_t type; };
  17.  
  18. typedef UInt<sizeof(FullInt)/2>::type HalfInt;
  19.  
  20. #include <typeinfo>
  21. #include <iostream>
  22.  
  23. int main()
  24. {
  25. std::cerr << sizeof(FullInt) << " " << sizeof(HalfInt) << std::endl;
  26. }
Success #stdin #stdout 0s 2880KB
stdin
Standard input is empty
stdout
Standard output is empty