Item 52. Specializing for Type Information

Class template explicit specialization and partial specialization are commonly used to produce versions of a primary class template that are customized to specific template arguments or classes of template arguments (see Class Template Explicit Specialization [46, 155] and Template Partial Specialization [47, 161]).

However, these language features are also commonly used in an inverse fashion: Rather than produce a specialization based on the properties of a type, the properties of a type are deduced from a specialization. Let’s look at a simple example:

image

Before we go on, I’d like to point out how simple ...

Get C++ Common Knowledge: Essential Intermediate Programming now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.