Value categories

From Cppreference

Jump to: navigation, search

When a C++ expression (an operator with its arguments) is evaluated, it results in a value. Each expression belongs to exactly one of the primary value categories.

Contents

[edit] Primary categories

[edit] lvalue

An lvalue is an expression that identifies a non-temporary object or a non-member function.

The following expressions are lvalues:

Properties:

[edit] rvalue (until C++11) / prvalue (since C++11)

A prvalue is an expression that identifies a temporary object (or a subobject thereof) or is a value not associated with any object.

The following expressions are prvalues:

Properties:

[edit] xvalue (since C++11)

An xvalue is an expression that identifies an "expiring" temporary object, that is, the object that may be moved from.

Only the following expressions are xvalues:

Properties:

[edit] Mixed categories

[edit] glvalue(since C++11)

A glvalue is an expression that is either an lvalue or an xvalue.

Properties:

[edit] rvalue (since C++11)

An rvalue is an expression that is either a prvalue or an xvalue.

Properties (note, these apply to both xvalues and prvalues, which means they apply to the pre-C++11 rvalues as well)