This is the code in question that appears in §13.3 of "C++ Primer", 5ed:
void swap(Foo &lhs, Foo &rhs)
{
using std::swap;
swap(lhs.h, rhs.h); // uses the HasPtr version of swap
// swap other members of type Foo
}
The book mentions the phenomenon of the class-specific swap not being hidden by the using declaration, and refers reader to §18.2.3:
I read that section and realized that this may be related to Argument-Dependent Lookup (ADL). The following is the excerption:
But I still have some vagueness in the understanding. My question is: does the ADL go before the normal scope lookup, or after the normal scope lookup? My current understanding is that ADL goes before the normal scope lookup, because otherwise it should be the std::swap that is used. I need confirmation if you think I am right, or please point out what mistake I've made if you think I am wrong. Thank you.