"IndexType" for ranges

Peter Alexander peter.alexander.au at gmail.com
Tue Oct 2 12:19:30 PDT 2012


On Tuesday, 2 October 2012 at 18:45:24 UTC, David Nadlinger wrote:
> On Tuesday, 2 October 2012 at 17:24:32 UTC, Andrei Alexandrescu 
> wrote:
>> Yes. Unfortunately there are few, few cases in which size_t is 
>> insufficient (e.g. an input range from a file or a large iota, 
>> both on 32-bit builds). I personally think these are too few 
>> to need formal support.
>
> I'd throw bit arrays into the mix, where 32 bit can also be 
> quite small. There might also be some other clever hacks using 
> custom index types for representing non-linear data structures 
> as ranges.
>
> The question is whether such ranges are likely to be used as 
> random access ranges. I can't come up with a compelling use 
> case right now, but I'd rather think twice before throwing 
> support for them out of the window and later regretting it. 
> Also, one of the simplest ranges (iota) not fitting the range 
> concept has somewhat of an odd aftertaste.

It's easy to think of random access ranges that could easily need 
more than size_t:

- The cartesian product of several smaller ranges
- a permutationsOf(r) range
- a subsetsOf(r) range

Any combinatoric range would easily use up 32-bit and 64-bit 
indexing. If 32-bit sometimes isn't enough, then neither is 
64-bit.

So, the question is, do we want to allow the use of BigInt 
indexing?



More information about the Digitalmars-d mailing list