bf(C++) supports syntactic constructs allowing programmers to define and use
completely general (or abstract) functions or classes, based on generic types
and/or (possibly inferred) constant values. In the chapters on abstract
containers (chapter ref(CONTAINERS)) and the tt(STL) (chapter ref(STL)) we've
already used these constructs, commonly known as the
    emi(template mechanism).

The template mechanism allows us to specify classes and algorithms, fairly
independently of the actual types for which the templates are eventually going
to be used. Whenever the template is used, the compiler generates code that is
tailored to the particular data type(s) used with the template. This code is
generated at i(compile-time) from the template's definition. The piece of
generated code is called an emi(instantiation) of the template.

In this chapter the syntactic peculiarities of templates are covered.  The
notions of em(template type parameter), em(template non-type parameter), and
emi(function template) are introduced and several examples of templates are
provided (both in this chapter and in chapter ref(CONCRETE)).  Template
em(classes) are covered in chapter ref(TEMPCLASS). For good reasons variadic
functions 
    hi(function: variadic)hi(variadic function) 
 are deprecated in bf(C++). However, em(variadic templates) tell us a
completely different story, and variadic templates are perfectly
acceptable. Both function- and class-templates can be defined as variadic
templates. Both forms are covered in section ref(VARIADIC).

Templates already offered by the language include the abstract containers
(cf. chapter ref(CONTAINERS)); the tt(string) (cf. chapter ref(String));
streams (cf. chapter ref(IOStreams)); and the generic algorithms (cf. chapter
ref(GENERIC)). So, templates play a central role in present-day bf(C++), and
should not be considered an esoteric feature of the language.

Templates should be approached somewhat similarly as generic algorithms:
they're a em(way of life); a bf(C++) software engineer should actively look
for opportunities to use them.  Initially, templates may appear to be rather
complex and you might be tempted to turn your back on them. However, over time
their strengths and benefits are more and more appreciated. Eventually you'll
be able to recognize opportunities for using templates. That's the time where
your efforts should no longer focus on constructing ordinary functions
 hi(ordinary function) and classes hi(ordinary class) (i.e., functions or
classes that are not templates), but on constructing templates.

This chapter starts by introducing em(function templates). The emphasis is on
the required syntax. This chapter lays the foundation upon which the other
chapters about templates are built.
