you nailed it - how do you tell which type, T1 or T2 should be the return value? And how do you write the code such that the correct precision is maintained in the result?
Answer: you specialize the template - to the point that you've fully specified all possible overload sequences and then the template has shown itself to be worthless in this case (except for the everything-is-a-T case).
you could try this:
template<class T>
double max(double x1, T x2) // if there's one double they're all double
{
return x1 > x2 ? x1 : x2;
}
to save some work - but you'll get an ambiguity if you try max(double, double) between the max is all T's and max T1 T2 definitions.
Thus, C++ can help you expand work to fill all available time with no trouble at all.
Or you could use a macro.