C++规范的哪一部分限制了参数相关查找不能在相关命名空间中找到函数模板?换句话说,为什么下面main
中的最后一个调用无法编译?
namespace ns {
struct foo {};
template<int i> void frob(foo const&) {}
void non_template(foo const&) {}
}
int main() {
ns::foo f;
non_template(f); // This is fine.
frob<0>(f); // This is not.
}
template<typename T> void bar(T) {}
,ADL 很好地工作,bar(f)
成功。 - sbi