Chapter 6. Programming with Templates

When Bjarne Stroustrup worked out the original C++ language design for templates, he referred to them as parameterized types: parameterized” because they are factored out of the template definition, and “types” because each class or function template typically varies by one or a set of types being operated on or contained. The actual type is later specified by the user.

Stroustrup later changed the name to the more general template. A single template definition serves as a prescription for the automatic generation of a unique instance of a function or class based on a user-specified value or type.

Although we have extensively used class templates, such as the vector and string classes, we haven’t yet implemented ...

Get Essential C++ 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.