Function templates
A function template defines how a family of functions can be generated. A family here means a group of functions that behave similarly. As shown in Figure 3.1 and outlined next, this includes two phases:
Figure 3.1 – Function template format
- Creating a function template, that is, the rules on how to write it
- Template instantiation, that is, the rules that are used to generate functions from their template
In part I of the preceding diagram, we discuss the format that will be used to create a function template for generic types, but with respect to the specialized template, which we also refer to as the primary template. Then, in part II, we introduce the three ways to generate functions from the template. Lastly, the Specialization and overloading subsection in this chapter tells us how to customize the primary template (by changing its behavior) for special types. In the following subsections, we will delve into...