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<<is_same_v<decltype(ptr), int()> <<" "<< is_same_v<decltype(ptr), int(A::*)()>;
  20. return 0;
  21. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:18:20: error: cannot call member function ‘int A::f() &&’ without object
  auto* ptr = &A::f();
                    ^
stdout
Standard output is empty