【发布时间】:2016-07-15 18:45:50
【问题描述】:
为什么 ADL 不选择以下部分特化?
template<class T>
void func1(T&){ // selected
...
}
namespace first{
template<class R>
struct foo{
friend void func1<>(foo<R>&){ // expected
cout << "foo.func1" <<endl;
}
};
}
foo<int> f;
func1(f);
【问题讨论】:
-
你的意思是
first::foo<int> f;? -
我认为这段代码无效。我得到“错误:在朋友声明中定义显式专业化'func1'”。 coliru.stacked-crooked.com/a/728b83afb9b416a4
-
代码不应该编译,你用的是什么编译器?
标签: templates c++14 template-specialization