A point from ISO draft n3290 section 3.4.2 paragraph 1:
When the postfix-expression in a function call is an unqualified-id, other namespaces not considered during the usual unqualified lookup may be searched, and in those namespaces, namespace-scope friend function declarations not otherwise visible may be found. These modifications to the search depend on the types of the arguments (and for template template arguments, the namespace of the template argument).
Here they said aboout “these modifications to the search depend on the types of the arguments / template template arguments / namespace of the template argument ” …Can any one expalin with an example please? I tried with argumetn types..please expalin with template template argument types & namespace of the template argument type
Consider a simple unqualified function call:
ADL means that
foois looked up not just in the enclosing scope, and the namespace that the call is in, but also the namespace of the type ofx. e.g. ifxis astd::vector<int>then namespacestdis also searched. Thus:is OK, and will call
std::swap().The lookup also depends on the namespace of any template arguments too, so if
xisstd::vector<mynamespace::myclass>thenmynamespaceis also included in the lookup. Thuswill call
mynamespace::foo().Finally, the lookup also extends to the namespaces of any templates used as template template parameters. e.g.
Even though
wrapperis in the global namespace,mynamespace::barwill be found, because the template template parameter used forxismynamespace::mytemplate.