fork download
  1. #include <iostream>
  2. #include <type_traits>
  3.  
  4. using namespace std;
  5.  
  6. struct A
  7. {
  8. int f()&&
  9. {
  10. return 0;
  11. }
  12. };
  13.  
  14. template<typename T1, typename T2>
  15. constexpr bool is_same_v = std::is_same<T1, T2>::value;
  16.  
  17. int main() {
  18. auto ptr = &A::f();
  19. std::cout<<
  20. is_same_v<decltype(ptr), int()> <<" "<< is_same_v<decltype(ptr), int(A::*)()>;
  21. return 0;
  22. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:18:19: error: cannot call member function ‘int A::f() &&’ without object
  auto ptr = &A::f();
                   ^
prog.cpp:20:2: error: template argument 1 is invalid
  is_same_v<decltype(ptr), int()> <<" "<< is_same_v<decltype(ptr), int(A::*)()>;
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
prog.cpp:20:42: error: template argument 1 is invalid
  is_same_v<decltype(ptr), int()> <<" "<< is_same_v<decltype(ptr), int(A::*)()>;
                                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
stdout
Standard output is empty