I have a function that is defined as follows:
template < class T> T doSomething(const T value, const T value2, const T value3)
{
T temp = value;
//Do stuff
return temp ;
}
in my main, I go to call it as follows:
doSomething(12.0, 23.0f, 2.0f);
I get an error saying no matching function for call doSomething(double, float, float).
I tried to used const_cast but it didn’t seem to fix the issue. Any help would be appreciated.
Your function definition uses same type “T” for every of three arguments.
C++ is not able to deduct types in cases like this.
Please choose way to fix:
template<typename A, typename B, typename C> A doSomething(const A& value, const B& value2, const C& value3) { A temp = value; //Do stuff return temp ; }