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 with the core fundamentals of templates in C++ and be able to understand large areas of template code and also write templates by yourself.
To start this chapter, we will explore the details of defining and...