fork download
  1. #include <iostream>
  2.  
  3. struct Foo
  4. {
  5. enum TYPE{ A , B , C };
  6. };
  7.  
  8. template<typename T>
  9. struct Bar
  10. {
  11. Bar()
  12. {
  13. T::TYPE = T::A;
  14. }
  15. };
  16.  
  17. int main()
  18. {
  19. Bar<Foo> bf;
  20. return 0;
  21. }
Compilation error #stdin compilation error #stdout 0.02s 2720KB
stdin
Standard input is empty
compilation info
prog.cpp: In constructor ‘Bar<T>::Bar() [with T = Foo]’:
prog.cpp:19:   instantiated from here
prog.cpp:13: error: dependent-name ‘T::TYPE’ is parsed as a non-type, but instantiation yields a type
prog.cpp:13: note: say ‘typename T::TYPE’ if a type is meant
stdout
Standard output is empty