Templates 101
A function template is just a pattern the compiler stamps out for each type you use it with. template<typename T> T max(T a, T b) { return a > b ? a : b; } generates separate functions for int, double, etc. at compile time. Zero runtime overhead.