相关疑难解决方法(0)

为什么ADL没有找到功能模板?

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.
}
Run Code Online (Sandbox Code Playgroud)

c++ template-function name-lookup argument-dependent-lookup

79
推荐指数
3
解决办法
3825
查看次数