September 2017
Intermediate to advanced
822 pages
26h 51m
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/max1.hpp
template<typename T> T max ...
Read now
Unlock full access