本文介绍了没有匹配函数调用函数模板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
template<class T, T i> void f(int[10][i]) { };
int main() {
int a[10][30];
f(a);
}
为什么 f(a)
fail?
推荐答案
f(a)
类型参数不能从非类型参数的类型中推导出。在这种情况下,编译器不能推导出模板参数的类型 T
。
f(a)
fails because a template type argument cannot be deduced from the type of a non-type argument. In this case the compiler cannot deduce the type of the template parameter T
.
尝试调用 f< int>(a);
这篇关于没有匹配函数调用函数模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!