|
-
November 2nd, 2002, 09:46 AM
#1
Difference in template resolving (MSVC, gcc)
Hi again!
This is the simple sample of code:
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!
-
November 4th, 2002, 07:21 AM
#2
As far as I know there is no way to change vc++’s behavior. It simply does not implement the whole standard. Your code works on Borland’s 5.5 and Comeau's 4.3.
Regards,
Last edited by zdf; November 4th, 2002 at 07:27 AM.
ZDF
What is good is twice as good if it's simple.
"Make it simple" is a complex task.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|