Learn New Techniques for Employing Templates in C++

Learn New Techniques for Employing Templates in C++

he idea of templates in C++ is more than ten years old. C++ templates were already documented in 1990 in the Annotated C++ Reference Manual and they had been described before that in more specialized publications. However, well over a decade later there was a dearth of literature that concentrates on the fundamental concepts and advanced techniques of this fascinating, complex, and powerful C++ feature. C++ Templates: The Complete Guide was written to address this issue.

The two authors approached the task with different backgrounds and with different intentions. David Vandevoorde, an experienced compiler implementer and member of the C++ Standard Committee Core Language Working Group, was interested in an exact and detailed description of all the power (and problems) of templates. Nico Josuttis, an “ordinary” application programmer and member of the C++ Standard Committee Library Working Group, was interested in understanding all the techniques of templates in a way that he could use and benefit from them.

As a consequence, you will see both conceptual introductions with day-to-day examples and detailed descriptions of the exact behavior of templates. Starting from the basic principles of templates and working up to the “art of template programming,” you will discover (or rediscover) techniques such as static polymorphism, policy classes, metaprogramming, and expression templates. You will also gain a deeper understanding of the C++ standard library, in which almost all code involves templates.

Chapter 16: “Templates and Inheritance” discusses named template arguments, empty base class optimization (EBCO), layout principles, members as base classes, and more .

Download the PDF of Chapter 16: “Templates and Inheritance”

Reproduced from C++ Templates: The Complete Guide by permission of Addison Wesley. ISBN 0201734842, copyright 2003. All rights reserved.


About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist