So I read this answer because I was confused about when values are considered as xvalue, like when a value is expiring/near the end of its lifetime. The sad thing is that I am still very confused.
Anyway, the quotation included this:
a class member access expression designating a non-static data member of non-reference type in which the object expression is an xvalue, or
a .* pointer-to-member expression in which the first operand is an xvalue and the second operand is a pointer to data member.
There was also an example included in the answer but it did not exemplify(I guess) "a .* pointer-to-member expression in which the first operand is an xvalue and the second operand is a pointer to data member.", so could anyone please show me one?
However, it does exemplify "a class member access expression designating a non-static data member of non-reference type in which the object expression is an xvalue" when doing f().m
and the fact that m
is an xvalue/an rvalue about to end makes sense to me since the f()
returns an rvalue reference. But a
is an lvalue, so what if you did a.m
, isn't that still an lvalue?
The confusion thing here is that this member access expression is still designating a non-static data member of non-reference type.. Or when saying "in which the object expression is an xvalue", does it mean that the class object has to be an rvalue?
The example mentioned in the answer:
struct A {
int m;
};
A&& operator+(A, A);
A&& f();
A a;
A&& ar = static_cast<A&&>(a);