Why doesn't my function skip trying to resolve to the incompatible template function, and default to resolving to the regular function? [duplicate]
This question already has an answer here: Why can't a template function resolve a pointer to a derived class to be a pointer to a base class 1 answer std::string nonSpecStr = "non specialized func"; std::string const nonTemplateStr = "non template func"; class Base {}; class Derived : public Base {}; template <typename T> std::string func(T * i_obj) { ( * i_obj) += 1; return nonSpecStr; } std::string func(Base * i_obj) { return nonTemplateStr; } void run() { // Function resolution order // 1. non-template functions // 2. specialized template functions // 3. template functions Base * base = new