Templates are used to create generic functions and generic classes and can operate on data without
knowing the nature of that data. They accomplish this by using a placeholder
data-type for which many other data types can be substituted.

For example, the following code uses a template to define a generic swap
function that can swap two variables of any type:

The template keyword is also used to indicate that a dependent name refers to a template. In contrast to the placement of the typename keyword, the template keyword is placed just before the name of the template member. For example: