For the first option (dot) the first expression shall be a glvalue having complete class type. For the second option (arrow) the first expression shall be a prvalue having pointer to complete class type. The expression E1->E2 is converted to the equivalent form (*(E1)).E2; the remainder of [expr.ref] will address only the first option (dot).68 In either case, the id-expression shall name a member of the class or of one of its base classes. [ Note: Because the name of a class is inserted in its class scope (Clause [class]), the name of a class is also considered a nested member of that class. — end note ] [ Note: [basic.lookup.classref] describes how names are looked up after the . and -> operators. — end note ]
According to this paragraph, the lvalue-to-rvalue conversion is applied to p
in the snippet below. But it is not applied to a
. Why does the standard prescribe a glvalue for the first option (dot) and a prvalue for the second option (arrow)?
struct A{ void f() {} };
A a;
A* p = new A;
int main() {
a.f();
p->f();
}