衆所周知,函數調用哪個返回類型是函數的函數是一個左值。函數類型的右值引用
A function call is an lvalue if the result type is an lvalue reference type or an rvalue reference to function type, an xvalue if the result type is an rvalue reference to object type, and a prvalue otherwise.
#include <iostream>
int a(){ return 1; }
int foo(){ return 1; }
int (&&bar())(){ return a; }
int main()
{
bar() = foo; //error: cannot convert 'int()' to 'int()' in assignment
}
什麼是錯的診斷消息?
非常好,謝謝。 –