fork download
  1. #include <iostream>
  2.  
  3. template <int N>
  4. struct A { };
  5.  
  6. template<typename T>
  7. struct X
  8. {
  9. static const unsigned number;
  10. };
  11.  
  12. template <typename T>
  13. const unsigned X<T>::number = sizeof(T);
  14.  
  15. template <int N>
  16. struct X<A<N>>
  17. {
  18. static const unsigned number = N * N;
  19. };
  20.  
  21. int main()
  22. {
  23. std::cout << X<A<3>>::number << '\n';
  24. std::cout << X<int>::number << '\n';
  25. std::cout << X<A<6>>::number << '\n';
  26. }
Success #stdin #stdout 0s 3140KB
stdin
Standard input is empty
stdout
9
4
36