Item 46. Class Template Explicit Specialization

Class template explicit specialization is straightforward. First, you need a general case to specialize. This general case is called the “primary” template.

template <typename T> class Heap;

The primary template has only to be declared to be specialized (as Heap is above), but it is usually also defined (as Heap is below):

image

Our primary template implements a heap data structure by putting an easy-to-use interface around the somewhat challenging standard library heap algorithms. A heap is a linearized tree structure that is optimized for insertion and retrieval. Pushing a value into a heap inserts ...

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.