I am still trying to figure out templates. I have read about the specialization rules and don't understand what is happening here.
I have defined the following in templates.h:
#include <iostream>
template <typename foo>
void f(foo p)
{
std::cout << "one" << std::endl;
}
template <typename bar>
void f(int p)
{
std::cout << "two" << std::endl;
}
Now if I include this and call it in my main like this
f(1);
f("x");
I get
one
one
Now the questions is, why is the first more specific than the second for ints? I feel like it should at least be ambiguous and not work at all.