View mode: basic / threaded / horizontal-split · Log in · Help
June 02, 2005
std.string.toString() with radix function
socket.d(111): function std.string.toString called with argument types:
        (ulong,int)
matches both:
        std.string.toString(long,uint)
and:
        std.string.toString(ulong,uint)


code:

int i = 15;
char [] ui;
ui = std.string.toString(cast(ulong)i,16);

what`s up with it?
June 02, 2005
Re: std.string.toString() with radix function
> socket.d(111): function std.string.toString called with argument types:
>          (ulong,int)
> matches both:
>          std.string.toString(long,uint)
> and:
>          std.string.toString(ulong,uint)
>
>
> code:
>
> int i = 15;
> char [] ui;
> ui = std.string.toString(cast(ulong)i,16);
>
> what`s up with it?

The parameter 16 is signed int by default. D has far simpler overloading  
rules than C++, and these produce the collision here. Use that instead:

ui = std.string.toString(cast(ulong)i, 16u);

Ciao
uwe
June 02, 2005
Re: std.string.toString() with radix function
Uwe Salomon napsal(a):
>> socket.d(111): function std.string.toString called with argument types:
>>          (ulong,int)
>> matches both:
>>          std.string.toString(long,uint)
>> and:
>>          std.string.toString(ulong,uint)
>>
>>
>> code:
>>
>> int i = 15;
>> char [] ui;
>> ui = std.string.toString(cast(ulong)i,16);
>>
>> what`s up with it?
> 
> 
> The parameter 16 is signed int by default. D has far simpler 
> overloading  rules than C++, and these produce the collision here. Use 
> that instead:
> 
> ui = std.string.toString(cast(ulong)i, 16u);
> 
> Ciao
> uwe
thanks, it works fine.
Top | Discussion index | About this forum | D home