I do not know about Boost, but all standard functions in <cmath> have overloads for three standard types, so you have, for example:
double cos(double); float cos(float); long double cos(long double);
instead of C:
double cos(double); float cosf(float); long double cosl(long double);
I'm not quite sure why you need a function template instead of Overload. For most mathematical functions there is no common implementation possible; the correct implementation will depend on accuracy, rounding rules, etc., which are different for each type. Thus, an alternative would be a template function without a common implementation and three specializations. And what does it buy you over the βsimplerβ overloaded functions?
source share