How to understand "ADL considers only function arguments, not template arguments"?

  argument-dependent-lookup, c++

As per this post(https://quuxplusone.github.io/blog/2019/04/26/what-is-adl/), which says that:

ADL considers only function arguments, not template arguments. Godbolt:

namespace A {
    struct A { operator int(); };
    struct X {};

    template<class T>
    void f(int);
}
namespace B {
    template<class T>
    void f();

    void test() {
        A::A a;
        f<A::X>();   // OK, ADL doesn't consider A::f, calls B::f
        f<A::X>(a);  // OK, ADL considers A::f because of A::A, calls A::f
        f<A::X>(42); // ERROR: ADL doesn't consider A::f
    }
}

template<class T> void A::f(int)‘s input parameter is int, how ADL would treat f<A::X>(a) as A::f(int)?

Source: Windows Questions C++

LEAVE A COMMENT