Great question! Function template specialization is a small niche and is usually not worth it. You may be a little confused for a reason.
You ask, "what's the fun syntax of a template without a type parameter?" Much! Specialized templates are very important and useful, and the good old swap example is a classic reason to consider it. The template embodies the idea of a general algorithm that works with any type, but often, if you know a little about the type you can add to a much better algorithm without calling code that requires you to know that something else is happening under the hood. Only the compiler knows, and it pulls the best implementation for real types at the moment when the algorithm is created with specific types, so your fast swap happens without a sorting algorithm that requires special cases. Specialization is a key part of creating universal programming useful in the real world (or we will have to use universal versions to get the required performance).
The specialization of the function template, although a bit niche, is for more obscure reasons. Think you read the Herb Sutter Summary ? So, if you do not want to be caught, it is recommended that you avoid specialized function templates. ( std::swap is an example of at least something that you need to specialize and not overload if you want to be ultra-compliant with the standard. We do this extensively in our code base here, and it works well in practice, although overloading, probably will work well enough.)
So, please specialize in everything that you like. Having specialized class templates that are far from ridiculous is often vital, but specializing function templates is not so useful.
source share