What does a template return?
04:46 24 Jan 2026
template 
inline T const& max (T const& a, T const&b)
{
return a < b ? b:a;
}

I call max(4, 4.2), shouldn’t the template function automatically return a float, since 4.2 is greater than 4?
In that case, when I am dealing with two different types, can the function still return a reference?
Since a temporary object would be created, don’t I have to explicitly specify which type the result should be converted to?

c++ templates