cpp/language/qualified lookup

A qualified name is a name that appears on the right hand side of the scope resolution operator (see also ). A qualified name may refer to a
 * class member (including static and non-static functions, types, templates, etc)
 * namespace member (including another namespace)
 * enumerator

If there is nothing on the left hand side of the, the lookup considers only declarations made in the global namespace scope (or introduced into the global namespace by a ). This makes it possible to refer to such names even if they were hidden by a local declaration:

Before name lookup can be performed for the name on the right hand side of, lookup must be completed for the name on its left hand side (unless a expression is used, or there is nothing on the left). This lookup, which may be qualified or unqualified, depending on whether there's another to the left of that name, considers only namespaces, class types, enumerations, and templates whose specializations are types. If the name found on the left does not designate a namespace or a class, enumeration, or dependent type, the program is ill-formed:

When a qualified name is used as a, then of the names used in the same declarator that follow that qualified name, but not the names that precede it, is performed in the scope of the member's class or namespace:

If is followed by the character  that is in turn followed by an identifier (that is, it specifies a destructor or pseudo-destructor), that identifier is looked up in the same scope as the name on the left hand side of

{{rev|since=c++11|

Enumerators
If the lookup of the left-hand side name comes up with an (either scoped or unscoped), the lookup of the right-hand side must result in an enumerator that belongs that enumeration, otherwise the program is ill-formed. }}

Class members
If the lookup of the left hand side name comes up with a class/struct or union name, the name on the right hand side of is looked up in the scope of that class (and so may find a declaration of a member of that class or of its base), with the following exceptions:
 * A destructor is looked up as described above (in the scope of the name to the left of ::).
 * A conversion-type-id in a function name is first looked up in the scope of the class. If not found, the name is then looked up in the current scope.
 * Names used in template arguments are looked up in the current scope (not in the scope of the template name).
 * Names in also consider class/enum names that are hidden by the name of a variable, data member, function, or enumerator declared in the same scope.

If the right hand side of names the same class as the left hand side, the name designates the  of that class. Such qualified name can only be used in a declaration of a constructor and in the for an. In those lookups where function names are ignored (that is, when looking up a name on the left of, when looking up a name in , or ), the same syntax resolves to the injected-class-name:

Qualified name lookup can be used to access a class member that is hidden by a nested declaration or by a derived class. A call to a qualified member function is never virtual:

Namespace members
If the name on the left of refers to a namespace or if there is nothing on the left of  (in which case it refers to the global namespace), the name that appears on the right hand side of  is looked up in the scope of that namespace, except that
 * names used in template arguments are looked up in the current scope:

Qualified lookup within the scope of a  first considers all declarations that are located in  and all declarations that are located in the  of  (and, transitively, in their inline namespace members). If there are no declarations in that set then it considers declarations in all namespaces named by found in  and in all transitive inline namespace members of. The rules are applied recursively:

It is allowed for the same declaration to be found more than once: