功能模板的部分专业化 [英] partial specialization of function template
问题描述
任何人都可以解释为什么部分专业化对函数模板无效,但对类模板来说很好。
Can anybody explain why partial specialization is not valid for function template but it's fine for class template.
我理解部分专门化可能会使编译器与函数重载混淆,但是我仍然需要更多的信息让我完全理解。
I understand partial specialization might make the compiler get confused with function overloading, but I still need more information to make me totally understand. Can anybody offer me some neat examples?
推荐答案
在这种情况下,困惑就足够了。
Getting confused is enough of a reason, in this case.
还有一个现有的替代解决方案:重载。委员会花了很多努力(在我看来,我不在那里)获得函数重载解析工作的模板,肯定的一部分原因包括不必解决较不通用的,硬的问题的功能模板部分专业化。
And there's an existing alternative solution: overloading. The committee spent a lot of effort (it seems to me, I wasn't there) getting function overload resolution working for templates, and surely part of the reason for that included not having to solve the less-general, hard problem of function template partial specialization.
这篇关于功能模板的部分专业化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!