template<class T>
void fn(T t){}
template<class T>
void fn(std::vector<T> vt){}
void f() {
std::vector<int> vt;
fn(vt);
}
I know that the second template function would be called, but i dont know the rules for template function matching.
template<class T>
void fn(T t){}
template<class T>
void fn(std::vector<T> vt){}
void f() {
std::vector<int> vt;
fn(vt);
}
I know that the second template function would be called, but i dont know the rules for template function matching.
Copyright © 2021 Jogjafile Inc.
Partial ordering takes place in the overload resolution for a call to a function template specialization.
For this case, the 2nd
fnis more specialized and wins in overload resolution, because it accepts types of instantiations ofstd::vectorthat is fewer than the 1st one, which could accept all the types.