Rvalue to lvalue conversion?

Why can't I convert rvalues ​​to lvalues? However, you can do the conversion in the opposite direction. Technically rvalues ​​have a memory address, right?

+7
source share
2 answers

You can:

int&& x = 3;

xnow lvalue. The so-called 'rvalue-reference' can bind to a temporary one , but all that has a name is an lvalue , so you need forward<>()it if you need to get it back.

, , rvalue- ( ), . , , , .

+1

, rvalues ​​ lvalues?

. , lvalues ​​lvalues, , . Rvalues ​​, , lvalues.

, rvalue , :

auto&& val = f(); // 'f' returns a prvalue.
0

All Articles