Description
In section 3.4.2 of the C++ standard, there is a special rule known as argument-dependent name lookup. This rule applies to calling functions declared within a namespace. Consider the sample code:
namespace A { class B {}; void f(B) {cout << "A::f() called" << endl;} void g() {cout << "A::g() called" << endl;} } int main() { A::B x; f(x); //g(); return 0; }In this usage, f() is called, but no names from the namespace A have been exported via using or using namespace, and this would normally be an error (as is true of the similar call to g()). But the argument type to f() is a class type A::B declared in the namespace, and in this case, the namespace where the class type was declared (A), is also included in the search to find f(). This lookup procedure is known as argument-dependent name lookup.
Concept
The sample program declares an object of class type A::B, and calls f() on this object. f() is found in the namespace, by application of the rule for argument-dependent name lookup.
Special Notes:
The argument-dependent name lookup rule has quite a few other cases, for example if the argument type is a template type.
Supported
Supported
Supported