fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <typeinfo>
  4. using namespace std;
  5.  
  6. template<class T>
  7. class Type_Identifier;
  8.  
  9. template<class T>
  10. struct A
  11. {
  12. const A& get_refrence(){
  13. return *this;
  14. }
  15. };
  16.  
  17.  
  18. template<class T>
  19. void test(T&& t){//T&& bayad bashe na T&
  20. auto& var = t.get_refrence();
  21.  
  22. Type_Identifier < decltype(var)> a;
  23. }
  24.  
  25. int main()
  26. {
  27. test(A<float>());
  28. test(A<std::string>());
  29. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In instantiation of ‘void test(T&&) [with T = A<float>]’:
prog.cpp:27:17:   required from here
prog.cpp:22:35: error: ‘Type_Identifier<const A<float>&> a’ has incomplete type
  Type_Identifier < decltype(var)> a;
                                   ^
prog.cpp: In instantiation of ‘void test(T&&) [with T = A<std::basic_string<char> >]’:
prog.cpp:28:23:   required from here
prog.cpp:22:35: error: ‘Type_Identifier<const A<std::basic_string<char> >&> a’ has incomplete type
stdout
Standard output is empty