Avatar ·

What is rvalue, lvalue, xvalue, glvalue and prvalue in C++11?

I'm learning C++11 and came across new terms: rvalue, lvalue, xvalue, glvalue and prvalue. Previously in old C++ I thought everything was simple: lvalue is what stands on the left side of an assignment (e.g., a variable), and rvalue is what stands on the right side (e.g., the number 42). But with the introduction of move semantics and std::move, it all became confusing.\n\nFor example, I wrote this code:\n\n```cpp\nint x = 10; // x — lvalue, 10 — prvalue\nint&& rref = std::move(x); // What is std::move(x)? And rref?\nint y = x + 5; // (x + 5) — what is this?\n```\n\nI've heard there are five categories, but I don't understand how to distinguish them in practice. The documentation talks about "identity" and "movability", but I need simple examples. Why does std::move(x) return an rvalue, even though x is an lvalue? And what is an xvalue? Please explain.