I would like to refine slightly accepted answer. It is not clear in the OP question, but the important part from the standard (cited by Kornel) is this (emphasis mine):
But when a function template with explicit template arguments is used, the call does not have the correct syntactic form
so what is prohibited is relying on ADL and using explicit template arguments. Unfortunately using non-type template arguments requires using explicit arguments (unless they have default values).
Below is sample code showing this.:
[live]
#include <string>
#include <utility>
namespace C {
struct B { };
template<class T> void f(T t){}
}
void g(C::B b) {
f(b); // OK
//f<C::B>(b); // ill-formed: not a function call, but only
// because explicit template argument were used
std::string s;
move(s); // OK
//move<std::string&>(s); // Error, again because
// explicit template argument were used
std::move<std::string&>(s); // Ok
}
int main()
{
C::B b;
g(b);
}
using namespace ns;
or thens::
qualification passes compilation. This is a good question. – Fyetemplate<typename T> void bar(T) {}
, ADL works fine,bar(f)
succeeds. – Panzer