Integer conversions too pedantic in 64-bit
Steven Schveighoffer
schveiguy at yahoo.com
Thu Feb 17 06:44:42 PST 2011
On Thu, 17 Feb 2011 09:45:14 -0500, Kagamin <spam at here.lot> wrote:
> dsimcha Wrote:
>
>> Funny, as simple as it is, this is a great idea for std.array because it
>> shortens the verbose cast(int) a.length to one extra character. You
>> could even put an assert in it to check in debug mode only that the
>> conversion is safe.
>
>> > int ilength(void[] a) @property
>> > {
>> > return cast(int)a.length;
>> > }
>
> I'm not sure the code is correct. I have a vague impression that void[]
> is like byte[], at least, it's used as such, and conversion from int[]
> to byte[] multiplies the length by 4.
Yes, David has proposed a corrected version on the Phobos mailing list:
http://lists.puremagic.com/pipermail/phobos/2011-February/004493.html
-Steve
More information about the Digitalmars-d
mailing list