www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Overloading oddness

Any reason why these are ambiguous?

  std.math.pow(10, cast(int)3);
  std.math.pow(10.0, cast(int)3);

The compiler says it matches both pow(real x, uint n) and pow(real x, int n).
If I've explicitly told the compiler the type of the n argument, surely that
should be enough? If I cast the x argument to a real, it compiles without
errors.

  std.math,pos(cast(real)10, 3);
  std.math.pow(cast(real)10.0, 3);

Odd - I'd have thought there might be a conflict with the n argument here, not
x - aren't double and real implicitly convertable?

John.
Oct 22 2008