so let's say I have the following function:
void foo(std::string strParam)
{
}
therefore strParam foo (string) will either be created using a copy (if arg was an lvalue) or move (if arg was an rvalue).
as everyone knows
foo("blah");
against
string bar = "blah";
foo(bar);
again,
string bar = "blah";
foo(move(bar));
and for the reference variable named rvalue
string &&temp =
foo(temp);
so I guess that means
string &&movedBar = move(bar);
foo(movedBar);
therefore we call
foo(move(bar))
differs from
string&& movedBar = move(bar);
foo(movedBar)
because one of them is an unnamed rvalue (xvalue) link, and the other is called an rvalue (lvalue) link
right, right?
source
share