fork(14) download
  1. #include <cstdio>
  2.  
  3. template<typename T> struct hi { };
  4. template<typename T> struct bye { };
  5.  
  6. template<typename T>
  7. struct Foo
  8. {
  9. struct Inner {
  10. template<typename U>
  11. void hi() { std::printf("hi!\n"); }
  12.  
  13. void bye() { std::printf("bye!\n"); }
  14. };
  15.  
  16. void sayStuff()
  17. {
  18. Inner i;
  19. i.template hi<T>();
  20. i.bye();
  21. }
  22. };
  23.  
  24.  
  25. int main() {
  26. Foo<int> f;
  27. f.sayStuff();
  28. return 0;
  29. }
Compilation error #stdin compilation error #stdout 0s 3140KB
stdin
Standard input is empty
compilation info
prog.cpp: In member function 'void Foo<T>::sayStuff()':
prog.cpp:19:5: error: invalid use of 'struct hi<T>'
   i.template hi<T>();
     ^
stdout
Standard output is empty