Search code examples
c++templatespartial-specialization

In C++, why template function cannot have partial specialization?


Why C++ has this restriction, in other words, if template function could also be partially-specialized, does it lead to any ambiguity or implementation complexity?

Why it cannot act like template class?


Solution

  • I believe the idea was that you can cover most of the cases by overloading function templates (something you can't do with classes) and the designer probably thought that the remaining cases were not worth the additional complications in overload resolution.