Overloading oddness

John C johnch_atms at hotmail.com
Wed Oct 22 03:09:14 PDT 2008


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.



More information about the Digitalmars-d mailing list