fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. template<typename T>
  5. struct F {
  6. static T const value;
  7. };
  8.  
  9. template<>
  10. struct F<int> { // Specialization
  11. static int const value;
  12. };
  13.  
  14. template struct F<int>;
  15.  
  16. template<typename T>
  17. T const F<T>::value = sizeof(T);
  18.  
  19. template<>
  20. int const F<int>::value = 42;
  21.  
  22. int main() {
  23.  
  24. struct F<int> ma;
  25. cout << ma.value;
  26.  
  27. return 0;
  28. }
Success #stdin #stdout 0s 3340KB
stdin
Standard input is empty
stdout
42