Knowing value categories in modern C++ is essential. Only when you know value categories, you can truly understand move semantics, and then you know how to write program efficiently.
Let get straight into it!
There are three primary categories. They are lvalue, xvalue and prvalue respectively, and two mixed categories (rvalue and glvalue). The relationship can be expressed in the following diagram:
graph TD E["Expression"] --> G["glvalue (Generalized lvalue)"] E --> R["rvalue"]
G --> L["lvalue"] G --> X["xvalue (eXpiring value)"]
R --> X R --> P["prvalue (Pure rvalue)"]
any expression in C++ can be categorized into one of the primary category. Here is the detail explanation
1.…