Weird issue with std.range.iota.length
Jonathan M Davis via Digitalmars-d
digitalmars-d at puremagic.com
Fri Feb 12 03:53:15 PST 2016
On Friday, 12 February 2016 at 10:37:31 UTC, tsbockman wrote:
> On Friday, 12 February 2016 at 10:34:32 UTC, tsbockman wrote:
>> Bounds checking. If iota's length is not expressible as a
>> `size_t`, convert it to one *safely* using `std.conv.to()`.
>
> Just to clarify - the bit about `std.conv.to()` is just an
> example.
>
> A better solution in this specific case would be to check once,
> while the iota() range is being constructed, whether its length
> is expressible as a `size_t` or not.
Yeah. I think that that's the best approach, but it does
unfortunately have the downside that you pretty much can't have a
range over all of the longs or ulongs on 32-bit systems (though
fortunately that should rarely be an issue, and I don't really
see a fix for that that doesn't cause problems with length and
other ranges).
- Jonathan M Davis
More information about the Digitalmars-d
mailing list