fork download
  1. #include <string>
  2.  
  3. template <class T, class U>
  4. struct sametype {};
  5.  
  6. template <class T>
  7. struct sametype<T,T> {typedef int same;};
  8.  
  9. int main() {
  10. int &refint();
  11. std::string str();
  12. std::string const conststr();
  13.  
  14. auto i1 = 1; // deduce(1) gives T=int so int i1
  15. auto i2 = i1; // deduce(i1) gives T=int so int i2
  16. auto i3 = refint(); // deduce(refint()) gives T=int so int i3
  17. const auto ci1 = i1; // deduce(i1) gives T=int so const int ci1
  18. auto i4 = ci1; // deduce(ci1) gives T=int so int i4
  19.  
  20. auto s1 = std::string(); // std::string s1
  21. auto s2 = str(); // std::string s2
  22. auto s3 = conststr(); // std::string s3
  23.  
  24. extern decltype(refint()) ir1; // int &i
  25.  
  26. sametype<decltype (i1), int>::same check_i1;
  27. sametype<decltype (i2), int>::same check_i2;
  28. sametype<decltype (i3), int>::same check_i3;
  29. sametype<decltype (i4), int>::same check_i4;
  30.  
  31. sametype<decltype (ci1), const int>::same check_ci1;
  32.  
  33. sametype<decltype (ir1), int&>::same check_ir1;
  34.  
  35. sametype<decltype (s1), std::string>::same check_s1;
  36. sametype<decltype (s2), std::string>::same check_s2;
  37. sametype<decltype (s3), std::string>::same check_s3;
  38. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
/home/lF3hoG/ccwdfdqY.o: In function `main':
prog.cpp:(.text.startup+0x13): undefined reference to `refint()'
prog.cpp:(.text.startup+0x1f): undefined reference to `str()'
prog.cpp:(.text.startup+0x28): undefined reference to `conststr()'
collect2: error: ld returned 1 exit status
stdout
Standard output is empty