struct S{
template<class T> operator T(){return T();}
operator int(){return 0;}
};
int main(){
S s;
int xi = s; // both template and non template are viable. Overload res chooses non tmpl
char xc = s; // both template and non template are viable. Overload res chooses tmpl
}
Edit: After first comment
struct B{
operator int(){return 0;}
};
struct S : B{
template<class T> operator T(){return T();}
operator int(){return 0;}
template<class T> operator T*(){return T();}
};
int main(){
S s;
int xi = s; // Overload reslution between operator T and operator int
char xc = s; // Overload resolution between operator T and operator int
int *pi = s; // Partial ordering involved between operator T() and operator T*()
}
The code above shows partial ordering and overload resolution when template/non-template both are involved.