A function template is a recipe for a family of functions: template <typename T> T larger(T a, T b) { return a < b ? b : a; }. When you call larger(3, 7) the compiler deduces T = int from the arguments and writes larger<int> for you; larger(2.5, 1.0) gets a double version. Each version is compiled separately, so a template costs nothing at run time compared with writing the function by hand.
Deduction needs the arguments to agree: larger(3, 7.5) does not compile, because T cannot be both int and double. Name the type yourself, larger<double>(3, 7.5), or give the template two parameters. A parameter that cannot be deduced at all, such as the type of a result, goes first so callers can name it.
A template only works for types that support what its body does. larger needs <, so it works for numbers, strings and any class with operator<, and fails to compile for a type without one. A template parameter can also stand for a callable: a lambda, a function or an object with operator().
One template, one compiled version per type it is used with.