The following program compiles (live demo), but I don't understand, why.
namespace N {
struct S {};
}
void Foo(N::S);
namespace Lib {
template <class T>
void Call() { Foo(T{}); }
void Foo();
}
int main()
{
Lib::Call<N::S>();
}
Shouldn't Lib::Foo
hide ::Foo
? Foo
in Call
is a dependent name, and evaluation of dependent names are supposed to be postponed until the instantiation of the template. How does name lookup work in this case?
In namespace Lib
Foo(N::S{})
can be called before the declaration of void Foo();
, but it cannot be called after the declaration, because Lib::Foo
hides ::Foo
. Lib::Call<N::S>();
is after the declaration, so when binding the name Foo
here, hiding should be in effect, shouldn't it?