Chapter 2: Template Fundamentals

In the previous chapter, we saw a short introduction to templates. What they are, how they are helpful, pros and cons for using templates, and, also, a few examples of function and class templates. In this chapter, we will explore this area in detail, and look at aspects such as template parameters, instantiation, specializations, aliases, and more. The main topics that you will learn about from this chapter are as follows:

  • How to define function templates, class templates, variable templates, and alias templates
  • What kinds of template parameters exist?
  • What is template instantiation?
  • What is template specialization?
  • How to use generic lambdas and lambda templates

By the end of this chapter, you will be familiar ...

Get Template Metaprogramming with 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.