fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. template <class T>
  5. struct A
  6. {
  7. void g()
  8. {
  9. int x = 5;
  10. {
  11. typename T::iterator<0> x;
  12. }
  13. }
  14. };
  15.  
  16. struct T4
  17. {
  18. struct Titerator
  19. {
  20. Titerator operator < (int value)
  21. {
  22. cout << "in operator < " << value << endl;
  23. return Titerator();
  24. }
  25. bool operator > (int value)
  26. {
  27. cout << "in operator > " << value << endl;
  28. return false;
  29. }
  30. };
  31. static Titerator iterator;
  32. };
  33.  
  34. T4::Titerator T4::iterator = T4::Titerator();
  35.  
  36. int main(int argc, char* argv[])
  37. {
  38. A<T4> a4; a4.g();
  39. return 0;
  40. }
  41.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In member function ‘void A<T>::g()’:
prog.cpp:11:25: error: non-template ‘iterator’ used as template
             typename T::iterator<0> x;
                         ^
prog.cpp:11:25: note: use ‘T::template iterator’ to indicate that it is a template
prog.cpp:11:25: error: declaration does not declare anything [-fpermissive]
prog.cpp: In instantiation of ‘void A<T>::g() [with T = T4]’:
prog.cpp:38:20:   required from here
prog.cpp:9:13: warning: unused variable ‘x’ [-Wunused-variable]
         int x = 5;
             ^
stdout
Standard output is empty