Template overload resolution: what happens when multiple templates match?
Partial ordering of overloaded function templates is performed to determine which one should be selected.
When the same function template specialization matches more than one overloaded function template (this often results from template argument deduction), partial ordering of overloaded function templates is performed to select the best match.
Specifically, partial ordering takes place in the following situations:
1) overload resolution for a call to a function template specialization
template<class X> void f(X a); template<class X> void f(X* a); int* p; f(p);
2) ...
...
Informally "A is more specialized than B" means "A accepts fewer types than B".
The 1st overload is selected because it only accepts arguments with one same type, while the 2nd one could accept arguments with two independent types.