I'm using G++ 4.2.1 on linux 2.6.x, and I am trying to get the compiler to automatically know what type I want a template to use based on the lvalue of an assignment like the following:
is this legal c++ code? or do I have to explicitly say:Code:template<class T>
T myfunc(double d)
{
return (T)d;
}
int i;
i = myfunc(1.0);
Code:i = myfunc<int>(1.0);