String implicit casts
Sean Kelly
sean at f4.ca
Thu Mar 9 15:17:07 PST 2006
lightoze wrote:
> I use this two functions:
>
> void x(char[] x) {}
> void x(wchar[] x) {}
>
> This works:
>
> x(cast(char[])"x");
> x(cast(wchar[])"x");
>
> This do not:
>
> x("x");
>
> I have found nothing about it in manual, can anyone tell me if it is normal or
> not?
It's normal, and is a result of the overloading rules in D. To resolve
an overload with string literals, try this:
x( "x"c ); // declare "x" as a char string
Templates can help as well, as in many cases you don't really need
separate overloads for each char type.
Sean
More information about the Digitalmars-d
mailing list