Chapter 26. Using Templates

<feature>
  • Implement generic programming with templates

  • Create and use function and class templates

  • Understand how to use template parameters

  • Convert existing classes into class templates

</feature>

Conceptualizing Templates

The introduction of experimental templates into C++ in the late 1980s was a major breakthrough for the language. After a decade of experimentation, modification, and fine-tuning, templates have become firmly rooted in the Standard C++ Library. Templates provide the basis of generic programming in C++ and make possible the Standard Template Library, one of the major features of the Standard C++ Library.

For years I wrote off templates as being just another programming trick that I could do without, but ...

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