私が知っていることによると、左辺値を右辺値参照にバインドすることはできません。 そして第二に、左辺値の式は、この2つの文には、次のコードでarecorrect場合、私はトラブルに少しだという事実によって、それは住所-のオペレータによるプレフィックス、(&)左辺値の左辺値と右辺値へのバインドと戻り値
することができ、認識です:
#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();
}
どこが間違っていますか?
'main'は' int'を返します。 – GManNickG
... return_foo()は左辺値です... –
以下のVitusはreturn_foo()がprvalue – Guillaume07