here figure out
- "has identity": address, a pointer, the user can determine whether two copies are identical.
- xvalue: has identity and can be moved from (e.g. the result of casting an lvalue to a rvalue reference.
here figure out
The following expressions are xvalue expressions:
3. a.m, the member of object expression, where a is an rvalue and m is a non-static data member of non-reference type;
here give an example
struct X { int n; };
X{4}; // prvalue: does not have an identity
X{4}.n; // xvalue: does have an identity and denotes resources
// that can be reused
but when i try to use & to cout the address of X{4}.n, the compiler deny to compile.
cout << &X{4}.n << endl; // error C2102: '&' requires l-value
does this mean i can never get an xvalue's address?
Aucun commentaire:
Enregistrer un commentaire