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 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.