Reputation: 1544
In other post, I came across
(5.2.9/8) An rvalue of type "pointer to member of D of type cv1 T" can be converted to an rvalue of type "pointer to member of B of type cv2 T", where B is a base class (clause 10) of D,
Note this from language standard. So my question,
int i = 0;
int *p = &i;
*p = 1;
Is a pointer is an lvalue in all the cases? When does it is treated as rvalue?
Upvotes: 8
Views: 8193
Reputation: 182763
A pointer is not the kind of thing that can be an rvalue or an lvalue. A pointer is a type. The only thing that can be an rvalue or an lvalue is an expression.
Consider this similar question: "Is an integer an lvalue or an rvalue". Well, neither. "3" is an integer, and an rvalue. 3=i;
is illegal. But i=3;
is legal if i
is an integer. So i
is an integer and an lvalue. 3
is an integer and a rvalue.
Upvotes: 23