Other things being equal, overload resolution prefers nontemplate functions for working with templates. However, in this case, all things are not equal. To match your overload for Base* , a database-based pointer mapping is required; no conversion is required to match the function pattern. Thus, the function template is selected for Derived* .
"A simple, albeit probable, error solution would be to make your Derived* to Base* before calling the function.
You could, theoretically, take the SFINAE approach, as Ben suggests, but you would have to explicitly disable the generic function template for any types for which you provide specializations, otherwise you will get perplexed bewilderment. This is even more incomprehensible and error prone than an explicit approach to lithography. (Although, someone here may know another way to get around the ambiguity of the overload, I would be interested to know if this was).
source share