Template Type Deduction (C++)
Consider the following Pseudocode:
template<typename T>
void f(ParamType param);A call can look like:
f(expr); // call f with some expressionDuring compilation, compilers use expr to deduce two types: one for T and one for ParamType. These types are frequently different, because ParamType often contains adornments, e.g., const or reference qualifiers. For example, if the template is declared like this,
template<typename T>
void f(const T& param); // ParamType is const T&and we have this call,
int x = 0;
f(x);T is deduced to be int, but ParamType is deduced to be const int&.