matching overloaded functions (std.string.toString)
Rick Mann
rmann-d-lang at latencyzero.com
Sat Feb 3 12:55:46 PST 2007
I'm not sure I understand the matching rules for overloaded functions. I have a type:
typedef int OSStatus;
and I want to call
OSStatus err;
toString(err);
but I get these errors:
function std.string.toString called with argument types:
(OSStatus)
matches both:
std.string.toString(char)
and:
std.string.toString(real)
It more readily matches toString(int). I realize the spec says that if a match is ambiguous, then it's an error, but it sure would be nice if this worked.
So, I tried defining my own toString(OSStatus):
char[]
toString(OSStatus inVal)
{
return std.string.toString(cast (int) inVal);
}
But I get the same error.
Can someone tell me why? Surely an exact match would be acceptable. Thanks!
More information about the Digitalmars-d-learn
mailing list