According to what I know it is not valid to bind a lvalue into a rvalue reference. And secondly, a lvalue expression is recognizable by the fact it can be prefix by adress-of operator, (&)
I'm a little bit in trouble if this two sentences arecorrect with the following codes :
#include<iostream>
struct Foo
{
Foo(Foo&& other)
{
std::cout << "move ctor called";
}
Foo(const Foo& other)
{
std::cout << "copy ctor called";
}
Foo(){}
};
Foo return_foo()
{
Foo f;
return f;
}
void main()
{
Foo f = return_foo(); // Move ctor is called, but return_foo() is a lvalue ??
std::cin.ignore();
}
Where I am wrong ?