partial specialization of function template

前端 未结 2 1684
挽巷
挽巷 2020-12-11 03:04

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

相关标签:
2条回答
  • 2020-12-11 03:29

    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.

    0 讨论(0)
  • 2020-12-11 03:37

    Now, I'm not an expert but I think the answer to the first part is that partial function specialisation would conflict (and be partially redundant) with function overloading. As for the second part, you can use a template struct that serves as a container for the thing you want to partially specialise.

    0 讨论(0)
提交回复
热议问题