【发布时间】:2020-10-01 19:12:00
【问题描述】:
我在编写模板函数特化时不小心犯了一个错误,结果构造通过了 VS17 的编译。 (下面包含的代码中的第三个构造)
这是一个有效的构造吗? 我该如何调用这个函数?
template <class T> void tempfunc(T t)
{
cout << "Generic Template Version\n";
}
template <>
void tempfunc<int>(int i) {
cout << "Template Specialization Version\n";
}
template <int> void tempfunc(int i)
{
cout << "Coding Mistake Version\n";
}
我无法调用第三个构造。
【问题讨论】:
标签: c++ template-specialization function-templates