2

I know that function templates can't be partially specialized, but I would like to know the reason for that.

Is it going to be changed in any upcoming C++ standard?

UPDATE: I disagree that the above-mentioned answer does provide an answer to the question.

beginpluses
  • 497
  • 2
  • 9
  • 1
    Fwiw, function specializations are second class citizens and really should be replaced by overload. A partial specialization would basically be the same. – NathanOliver Jun 25 '19 at 23:17

1 Answers1

2

Specialization is a form of dispatching.

So is overloading.

Having both would make the already complex system insane.

Yakk - Adam Nevraumont
  • 262,606
  • 27
  • 330
  • 524
  • 2
    Thank you very much! Could you please add some details to your answer? An example demonstrating the problems? – beginpluses Jun 25 '19 at 22:56
  • @begin I'm not sure how I'd demonstrate a non-existent extension to C++ to someone who doesn't already quake in fear at the complexity of determining which overload is used when you call an overloaded template function. So... – Yakk - Adam Nevraumont Jun 25 '19 at 23:38
  • What do you think about this then "I guess it was just an oversight (considering that you can always get the partial specialization effect with more verbose code, by placing the function as a static member of a class)." From https://stackoverflow.com/questions/5101516/why-function-template-cannot-be-partially-specialized – beginpluses Jun 27 '19 at 17:34
  • @beginpluses That was an answer I long downvoted. So I don't think much of that answer? – Yakk - Adam Nevraumont Jun 27 '19 at 18:12