众所周知,函数调用哪个返回类型是函数的函数是一个左值。函数类型的右值引用
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
}
什么是错的诊断消息?
非常好,谢谢。 –