Suppose I have a template function and it's specialization.
template<class T>
void myfunction(T whatever)
{
}
template<>
void myfunction(int whatever)
{
//whatever
}
As far as I know, if I never call myfunction
is the my programm, the template will never be instantiated and will go into the binary code only regarded as a template(correct me if I am wrong). My question is, will the specialization of myfunction
be instantiated in this case?
If yes, how would it differ from the following definition of myfunction
void myfunction(int whatever)
{
//This is the version of myfunction with the same interface as the template specialization of myfunction above,
//except it is not templated.
}