Ranges longer than size_t.max
Peter Alexander
peter.alexander.au at gmail.com
Fri Dec 28 18:24:54 PST 2012
On Saturday, 29 December 2012 at 01:56:04 UTC, Simen Kjaeraas
wrote:
> @property auto length()
> {
> CommonType!(staticMap!(LengthType, R)) result = 0;
> foreach (i, Unused; R)
> {
> result += source[i].length;
> }
> return result;
> }
>
> This would thus support BigInt .length just as well as size_t,
> byte,
> or whatever.
This doesn't solve the issue. For example, even with your update,
the code snippet I provided in the original post with iota and
chain would still break (assuming iota(size_t.max).length returns
a size_t).
Also, if we allow BigInt, even with better support in CommonType
it would significantly complicate Phobos with LengthType!Range
popping up everywhere.
More information about the Digitalmars-d
mailing list