C++11 introduced new value categories, one of them is xvalue
.
It is explained by Stroustrup as something like (im
category): "it is a value, which has identity, but can be moved from".
Another source, cppreference explains:
a glvalue is an expression whose evaluation determines the identity of an object, bit-field, or function;
And xvalue
is a glvalue
, so this is statement is true for xvalue
too.
Now, I thought that if an xvalue
has identity, then I can check if two xvalue
s refer to the same object, so I take the address of an xvalue
. As it turned out, it is not allowed:
int main() {
int a;
int *b = &std::move(a); // NOT ALLOWED
}
What does it mean that xvalue
has identity?