[basic.lookup.classref] (original) (raw)
6 Basics [basic]
6.5 Name lookup [basic.lookup]
6.5.6 Class member access [basic.lookup.classref]
In a class member access expression, if the .or -> token is immediately followed by an identifierfollowed by a <, the identifier is looked up to determine whether the < is the beginning of a template argument list ([temp.names]) or a less-than operator.
The identifier is first looked up in the class of the object expression ([class.member.lookup]).
If the identifier is not found, it is then looked up in the context of the entirepostfix-expression and shall name a template whose specializations are types.
If the type T of the object expression is of a class type C, the type-name is also looked up in the scope of class C.
At least one of the lookups shall find a name that refers to cv T.
[Example 1: struct A { };struct B { struct A { };void f(::A* a);};void B::f(::A* a) { a->~A(); } — _end example_]
If the id-expression in a class member access is aqualified-id of the form_class-name-or-namespace-name_::... the class-name-or-namespace-name following the . or-> operator is first looked up in the class of the object expression ([class.member.lookup]) and the name, if found, is used.
Otherwise it is looked up in the context of the entirepostfix-expression.
[Note 1:
See [basic.lookup.qual], which describes the lookup of a name before ::, which will only find a type or namespace name.
— _end note_]
Otherwise it is looked up in the context of the entire postfix-expression.
In each of these lookups, only names that denote types or templates whose specializations are types are considered.
[Example 2: struct A { };namespace N { struct A { void g() { } template <class T> operator T();};} int main() { N::A a; a.operator A(); } — _end example_]