I have been reading the interesting topic Why Not Specialize Function Templates? and somewhere encountered the following example.
struct Base{};
template<class T>
void f(T) { cout << "foo"; }
template<class T>
void functionSelector(T t)
{
f(Base());
f(t);
}
void f(Base) { cout << "bar"; }
int main ()
{
functionSelector(Base());
return 0;
}
This small program outputs
foobar
and I definitely could not understand why it didn't output
barbar
Any help would be appreciated.