C++ template specialization of function: “illegal use of explicit template arguments”

﹥>﹥吖頭↗ 提交于 2019-12-03 00:10:01

Function templates cannot be partially specialised, only fully, i.e. like that:

template<>
void spec1<char, int>()
{

}

For why function templates cannot be partially specialised, you may want to read this.

When you specialise partially (only possible for classes), you'd have to do it like that:

template <typename T1>
class class1<T1, int>
{

};

so you have to list T1 again.

The way your specialisations are written, they would be ambiguous for spec1<int, int>.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!