Description
The binary operator .* binds its second operand, which shall be of type “pointer to member of T” to its first operand, which shall be a glvalue of class T or of a class of which T is an unambiguous and accessible base class. The result is an object or a function of the type specified by the second operand.
As aforementioned, the second operand has the type of “pointer to member of T”, but the rule says the result is an object or a function of the type specified by the second operand, Is it a contradiction here?
Maybe we should say
The result is an object or a function of the type specified by the entity to which the second operand refers.
Can E2
be the second operand of the class member access operator?
Abbreviating pm-expression.*cast-expression as E1.*E2, E1 is called the object expression. If the dynamic type of E1 does not contain the member to which E2 refers, the behavior is undefined. Otherwise, the expression E1 is sequenced before the expression E2.
The restrictions on cv-qualification, and the manner in which the cv-qualifiers of the operands are combined to produce the cv-qualifiers of the result, are the same as the rules for E1.E2 given in [expr.ref].
Again, E2
still has the type of “pointer to member of T” in the context of the above rule, which means E2
is invalid to be the second operand of the expression E1.E2.
Activity
jwakely commentedon Jun 17, 2021
No. The type specified by the second operand does not mean the type of the second operand.
A pointer to member of type
int T::*
specifies a result of typeint
. A pointer to member of typevoid (T::*)(char)
specifies a result of typevoid(char)
.Yes, that one seems wrong.
xmh0511 commentedon Jun 17, 2021
Please ask which is the normative rule in the standard gives that meaning?
jwakely commentedon Jun 17, 2021
There isn't a rule saying "the type specified by" means "the same type" either, not in the standard and not in English.
xmh0511 commentedon Jun 17, 2021
Yes, that is what I'm concerning here. The phrase "the type specified by" gives an ambiguous meaning, we can read it in either meaning. So, I think we should replace it with more clear wording to avoid the potential misunderstanding.
jwakely commentedon Jun 17, 2021
If you choose to read the words a certain way, and that creates a contradiction or nonsensical meaning, maybe you shouldn't read them that way.
xmh0511 commentedon Jun 17, 2021
Agree with you. But I think we could improve the wording to make it to be more readable. After all, in the other place, such as "T&", we use the utterance "the referenced type" or "the type to which the reference refers" and so on. Have a similar way for pointer type. Why not use a similar tone here instead use the "the type specified by..."?