This is plain old unqualified name lookup, specified in §3.4.1 [basic.lookup.unqual]:
1 In all the cases listed in 3.4.1, the scopes are searched for a
declaration in the order listed in each of the respective categories;
name lookup ends as soon as a declaration is found for the name. If no
declaration is found, the program is ill-formed.
8 For the members of a class X
, a name used in a member function
body, in a default argument, in an exception-specification, in the
brace-or-equal-initializer of a non-static data member (9.2), or in the definition of a class member outside of the definition of X,
following the member’s declarator-id, shall be declared in one of
the following ways:
- before its use in the block in which it is used or in an enclosing block (6.3), or
- shall be a member of class
X
or be a member of a base class of X
(10.2), or
- if
X
is a nested class of class Y
(9.7), shall be a member of Y
, or shall be a member of a base class of Y
(this lookup applies
in turn to Y
’s enclosing classes, starting with the innermost
enclosing class), or
- if
X
is a local class (9.8) or is a nested class of a local class, before the definition of class X
in a block enclosing the definition
of class X
, or
- if
X
is a member of namespace N
, or is a nested class of a class that is a member of N
, or is a local class or a nested class within
a local class of a function that is a member of N
, before the use of
the name, in namespace N
or in one of N
’s enclosing namespaces.
Note first that name lookup stops as soon as a declaration is found. So if you have using ::foo;
in callFoo()
, lookup for foo
will end there and never touch the second bullet point; if you don't have it, lookup for foo
will find the member foo()
at the second bullet point and never search elsewhere. The way unqualified name lookup is specified means that you will either find class members or non-class-members, but never both.
This is also noted in §13.1.1.1 [over.call.func]/p3:
In unqualified function calls, the name is not qualified by an -> or .
operator and has the more general form of a primary-expression. The
name is looked up in the context of the function call following the
normal rules for name lookup in function calls (3.4). The function
declarations found by that lookup constitute the set of candidate
functions. Because of the rules for name lookup, the set of candidate
functions consists (1) entirely of non-member functions or (2)
entirely of member functions of some class T
. In case (1), the argument list
is the same as the expression-list in the call. In case (2), the
argument list is the expression-list in the call augmented by the
addition of an implied object argument as in a qualified function
call.
A using-declaration at class scope must name a base class member (§7.3.3 [namespace.udecl]/p3):
In a using-declaration used as a member-declaration, the
nested-name-specifier shall name a base class of the class being defined.