LeaetherStrip
November 2nd, 2002, 08:46 AM
Hi again!
This is the simple sample of code:
//...
template<class T, T t_inst>
void dosmth(T& ret){
ret = t_inst;
}
void dosmth(int& ret){
ret = 5;
}
int main(int argc, char* argv[])
{
int toret;
dosmth(toret);
return 0;
}
By design, void dosmth(int&) should be used. It's really so - in gcc. But Visual C++ refuses to compile this code, saying: error C2783: 'void __cdecl dosmth(T &)' : could not deduce template argument for 't_inst'.
Why VC doesn't use non-template function? And how this behaviour can be overriden?
Regards!
This is the simple sample of code:
//...
template<class T, T t_inst>
void dosmth(T& ret){
ret = t_inst;
}
void dosmth(int& ret){
ret = 5;
}
int main(int argc, char* argv[])
{
int toret;
dosmth(toret);
return 0;
}
By design, void dosmth(int&) should be used. It's really so - in gcc. But Visual C++ refuses to compile this code, saying: error C2783: 'void __cdecl dosmth(T &)' : could not deduce template argument for 't_inst'.
Why VC doesn't use non-template function? And how this behaviour can be overriden?
Regards!