Lets say I have template class with template function. Example:
template<typename T>
class example
{
T some_member;
template<typename X>
example& foo(X& val)
{
/* general stuff */
return *this;
}
// rest of class
};
What I'm failing to achieve is to make specialization for this method which takes as argument object of type example < T > (same type as caller's). Little example to show how it suppose to work:
example<int> exampleObj;
example<int> sameTypeObj;
int diffrentType1;
example<double> diffrentType2;
exampleObj.foo(diffrentType1); // general template used
exampleObj.foo(diffrentType2); // general template used
exampleObj.foo(sameTypeObj); // specialization used
You can overload, but you cannot specialize, since there is no partial template function specialization.
example& foo(example&)
{
}
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments