I would like a clarification about this particular case:
class Test
{
Test& operator=(const Test& copy)
{
...
}
Test() = default;
}
Test a;
Test b;
b = a; //Is "a" converted to an rvalue?
"a" is an lvalue, however it is now the righthand operand of the assignment. Does it mean it gets converted to an rvalue?
This code doesn't compile:
class Test
{
Test& operator=(Test&& copy)
{
...
}
Test() = default;
}
Test a;
Test b;
a = b; //Error
But this one does:
class Test
{
Test& operator=(Test& copy)
{
...
}
Test() = default;
}
Test a;
Test b;
a = b; //OK
Since an lvalue reference cannot bind to an rvalue, does it mean a conversion is not happening here? If that is the case, when does an implicit lvalue-to-rvalue conversion happen? (Other than the case of the operator+ with primitive types)