fork(1) download
  1. #include <iostream>
  2.  
  3. struct Outer
  4. {
  5. template<typename T>
  6. struct Inner
  7. {
  8. };
  9.  
  10. void f()
  11. {
  12. Inner<int> i1;
  13. Inner<double> i2;
  14. }
  15. };
  16.  
  17. int main()
  18. {
  19. Outer o;
  20. o.f();
  21. }
  22.  
  23. template<>
  24. struct Outer::Inner<double>
  25. {
  26. };
  27.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In member function ‘void Outer::f()’:
prog.cpp:12:14: warning: unused variable ‘i1’ [-Wunused-variable]
   Inner<int> i1;
              ^
prog.cpp:13:17: warning: unused variable ‘i2’ [-Wunused-variable]
   Inner<double> i2;
                 ^
prog.cpp: At global scope:
prog.cpp:24:15: error: specialization of ‘Outer::Inner<double>’ after instantiation
 struct Outer::Inner<double> 
               ^
prog.cpp:24:15: error: redefinition of ‘struct Outer::Inner<double>’
prog.cpp:6:9: error: previous definition of ‘struct Outer::Inner<double>’
  struct Inner
         ^
stdout
Standard output is empty