vendredi 23 janvier 2015

Am I correct in my observation below about §9.3.1/3 in the C++ Standard?

§9.3.1/3 (emphasis is mine):



When an id-expression (5.1) that is not part of a class member access syntax (5.2.5) and not used to form a pointer to member (5.3.1) is used in a member of class X in a context where this can be used (5.1.1), if name lookup (3.4) resolves the name in the id-expression to a non-static non-type member of some class C, and if either the id-expression is potentially evaluated or C is X or a base class of X, the id-expression is transformed into a class member access expression (5.2.5) using (*this) (9.3.2) as the postfix-expression to the left of the . operator. [ Note: If C is not X or a base class of X, the class member access expression is ill-formed. — end note ] Similarly during name lookup, when an unqualified-id (5.1) used in the definition of a member function for class X resolves to a static member, an enumerator or a nested type of class X or of a base class of X, the unqualified-id is transformed into a qualified-id (5.1) in which the nested-name-specifier names the class of the member function.



Shouldn't the Note above be more specific? I mean something like this: `If the id-expression is potentially evaluated and if C is not X or a base class of X, the class member access expression is ill-formed."


Note that if the id-expression is an unevaluated operand the code will be valid even if C is not X, nor a base class of X, although in this case the transformation alluded in the paragraph will not take place.


Aucun commentaire:

Enregistrer un commentaire