fork(3) download
  1. #include <iostream>
  2.  
  3. struct Outer
  4. {
  5. template<typename T>
  6. void go()
  7. {
  8. std::cout << Test<T>::f() << std::endl;
  9. }
  10. private:
  11. template<typename T>
  12. struct Test
  13. {
  14. static int f();
  15. };
  16. };
  17.  
  18. extern template struct Outer::Test<int>;
  19. extern template struct Outer::Test<double>;
  20.  
  21. int main()
  22. {
  23. Outer o;
  24. o.go<int>();
  25. o.go<double>();
  26. }
  27.  
  28. template<>
  29. int Outer::Test<int>::f()
  30. {
  31. return 1;
  32. }
  33. template<>
  34. int Outer::Test<double>::f()
  35. {
  36. return 2;
  37. }
  38.  
  39.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:29:25: error: specialization of ‘static int Outer::Test<T>::f() [with T = int]’ after instantiation
 int Outer::Test<int>::f()
                         ^
prog.cpp:34:28: error: specialization of ‘static int Outer::Test<T>::f() [with T = double]’ after instantiation
 int Outer::Test<double>::f()
                            ^
stdout
Standard output is empty