glvalue

glvalue(廣義左值)表示式是具有標識的任何表示式,無論它是否可以移動。此類別包括左值(具有標識但不能移動的表示式)和 xvalues(具有標識且可以移動的表示式),但不包括 prvalues(沒有標識的表示式)。

如果表示式有名稱,則為 glvalue:

struct X { int n; };
X foo();

X x;
x; // has a name, so it's a glvalue
std::move(x); // has a name (we're moving from "x"), so it's a glvalue
              // can be moved from, so it's an xvalue not an lvalue

foo(); // has no name, so is a prvalue, not a glvalue
X{};   // temporary has no name, so is a prvalue, not a glvalue
X{}.n; // HAS a name, so is a glvalue. can be moved from, so it's an xvalue