std.digest toHexString

Carl Sturtivant via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Mar 16 10:20:10 PDT 2017


On Thursday, 16 March 2017 at 16:59:40 UTC, Adam D. Ruppe wrote:
>> Yet the documentation says there's a toHexString that returns 
>> a string.
>
> Yes, indeed, it returns a string if it is passed a dynamic 
> array.

Ah, that's the distinction, should have noticed.

> Remember though, like I warned on my doc fork, overload 
> resolution NEVER looks at the left hand side of the equation, 
> it is always done on arguments alone.
>
> The stupid auto return stuff Phobos loves so much obscures it, 
> but md5Of returns a ubyte[16].
>
> That calls the first overload, the one that returns char[num*2]

OK, but if I try to do this,

char[2] u;
string s = u;

the compiler will complain: Error: cannot implicitly convert 
expression (u) of type char[2] to string. So why does it allow 
the template instantiation  of return type char[num*2] in place 
of u above?




More information about the Digitalmars-d-learn mailing list