In C ++, does it make sense to say that a variable is of type rvalue reference?

What I'm thinking of something like X&& x = static_cast<X&&>(obj_x);is that, despite the appearance, xends up being a normal reference to lvalue. I recently met this article where Scott Meyers insists that there xwill be lvalue links like rvalue. Is it really significant, or is this difference without a difference? In particular, given either

X&& x = static_cast<X&&>(obj_x)

or

X& x = obj_x;

Is there any subsequent code that will behave differently for these two definitions x?

+4
source share
1 answer

, R- ( ).

, , no, no x - (, cpplearner, decltype()). x , ( , -).

, , , l- . ? r- - -. , , . , , . , , , . std:: move (mything), mything [ ].

, , , , . , . .

+1

Source: https://habr.com/ru/post/1648076/


All Articles