fork download
  1. #include <iostream>
  2. #include <typeinfo>
  3.  
  4. class Base {
  5. public:
  6. typedef Base Type;
  7. // using T2 = Base;
  8. // typedef decltype(*this) H;
  9. Base() {}
  10. };
  11.  
  12. class Next :public Base{
  13. public:
  14. typedef Next Type;
  15. // using T2 = Next;
  16. // typedef decltype(*this) H;
  17. Next() {}
  18. };
  19.  
  20. template<class T>
  21. class TGetter {
  22. public:
  23. typedef T Ty;
  24.  
  25. };
  26.  
  27. int main()
  28. {
  29. Next N;
  30. Base *p = &N;
  31. //using T = decltype(p);
  32. //typename (*T)::T X;
  33. TGetter<decltype(*p)>::Ty::Type T();
  34. std::cout << typeid(T).name() << std::endl;//need Next!
  35.  
  36.  
  37. return 0;
  38. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:33:34: error: qualified-id in declaration before ‘T’
  TGetter<decltype(*p)>::Ty::Type T();
                                  ^
prog.cpp:34:22: error: ‘T’ was not declared in this scope
  std::cout << typeid(T).name() << std::endl;//need Next!
                      ^
stdout
Standard output is empty