Item 47. Template Partial Specialization
Let’s get it straight: you can’t partially specialize function templates. It’s just not a part of the C++ language (although it may be some day). What you probably want to do is overload them (see Overloading Function Templates [58, 213]). Accordingly, we are considering only class templates in this item.
The way class template partial specialization works is straightforward. As with complete specialization, you first need a general case—or primary template—to specialize. Let’s use our Heap
template from Class Template Explicit Specialization [46, 155]:
template <typename T> class Heap;
Explicit specialization (also known colloquially as “complete” specialization) is used to customize a class template ...
Get C++ Common Knowledge: Essential Intermediate Programming now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.