Josuttis and Vandervoorde mentioned, that for dependent unqualified names compiler applies ordinary lookup on first phase and ADL on second. Then it combines overload set. Something like this:
struct B{};
void bar(int){} // first overload
template <class T>
void foo(T t)
{
bar(2, t);
}
void bar(int, B){} // second overload
int main() {
foo(B{}); // works just fine, calls second overload
}
But if dependent name is name of member function then this principle doesn't work:
struct B{};
struct A{
template <class T>
void foo(T t)
{
bar(2, t);
}
void bar(int){} // first overload
};
void bar(int, B){} // second overload
int main() {
A a;
a.foo(B{}); // gives error
}
Why is it? I was wondering if somebody could point on notes from Standard