fork(1) download
  1. #include <iostream>
  2.  
  3. template <class T> class X { /* ... */ };
  4. void f()
  5. {
  6. struct S { /* ... */ };
  7.  
  8. X<S> x3; // error: local type used as template-argument
  9. X<S*> x4; // error: pointer to local type used as template-argument
  10. }
  11.  
  12. int main() {
  13.  
  14. f();
  15.  
  16. return 0;
  17. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘void f()’:
prog.cpp:8:6: error: template argument for ‘template<class T> class X’ uses local type ‘f()::S’
   X<S> x3;  // error: local type used as template-argument
      ^
prog.cpp:8:6: error:   trying to instantiate ‘template<class T> class X’
prog.cpp:8:10: error: invalid type in declaration before ‘;’ token
   X<S> x3;  // error: local type used as template-argument
          ^
prog.cpp:9:7: error: template argument for ‘template<class T> class X’ uses local type ‘f()::S*’
   X<S*> x4; // error: pointer to local type used as template-argument
       ^
prog.cpp:9:7: error:   trying to instantiate ‘template<class T> class X’
prog.cpp:9:11: error: invalid type in declaration before ‘;’ token
   X<S*> x4; // error: pointer to local type used as template-argument
           ^
prog.cpp:8:8: warning: unused variable ‘x3’ [-Wunused-variable]
   X<S> x3;  // error: local type used as template-argument
        ^
prog.cpp:9:9: warning: unused variable ‘x4’ [-Wunused-variable]
   X<S*> x4; // error: pointer to local type used as template-argument
         ^
stdout
Standard output is empty