Mathematical functions like pow (), sin (), etc. are templatized in more modern C ++ implementations. The reason for the ambiguity is that it is not clear what you want to do. If you send both arguments the same, you apparently want the calculations to be done with some precision. If they differ from each other, then you want to calculate with higher accuracy and increase the efficiency of the operand with lower accuracy, or you want to lower the higher accuracy to less accuracy, and then perform the calculations with less accuracy. i.e.
float a,b; double c,d; pow(a,b); // not ambiguous, done at float precision pow(c,d); // not ambiguous, done at double precision pow(a,c); // ambiguous, gives error pow((double)a,c); // not ambiguous, performs computation at double precision pow(a,(float)c); // not ambiguous, gives computation at float precision, but c might lose precision in the down cast
Andrew Selle
source share