Weird issue with std.range.iota.length
ixid via Digitalmars-d
digitalmars-d at puremagic.com
Fri Feb 12 08:52:17 PST 2016
On Friday, 12 February 2016 at 15:59:09 UTC, Jonathan M Davis
wrote:
> It would be far better IMHO to just do a check in iota and
> throw a RangeError if the length wouldn't fit in size_t. Having
> length ever be anything other than size_t is just going to
> cause problems with other ranges. On 32-bit systems, you lose
> out on the ability to have a range that covers all values of
> long or ulong, but that's of very limited usefulness anyway,
> and as long as the number of elements is no greater than
> size_t.max, it would be fine - which would cover virtually all
> use cases. No, it's not perfect, but allowing length to be
> anything but size_t just causes bugs - especially in generic
> code.
>
> - Jonathan M Davis
What about a template overload where you can set the length type
as separate from the type of the range elements?
More information about the Digitalmars-d
mailing list