Menu

Deep dive into C++ value categories
📰

Deep dive into C++ value categories

DEV Community: cpp·llzzz·18 days ago
#HDXVm50J
#devtocpp#devto#dev#lvalue#prvalue
Reading 0:00
15s threshold

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.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.