November 2002
Intermediate to advanced
552 pages
10h 52m
English
This chapter introduces function templates. Function templates are functions that are parameterized so that they represent a family of functions.
Function templates provide a functional behavior that can be called for different types. In other words, a function template represents a family of functions. The representation looks a lot like an ordinary function, except that some elements of the function are left undetermined: These elements are parameterized. To illustrate, let’s look at a simple example.
The following is a function template that returns the maximum of two values:
// basics/max.hpp template <typename T> inline T const& max (T const& ...
Read now
Unlock full access