Ranges longer than size_t.max

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Sat Dec 29 06:23:11 PST 2012


On 12/29/12 4:00 AM, Peter Alexander wrote:
> On Saturday, 29 December 2012 at 03:28:47 UTC, Andrei Alexandrescu wrote:
>> On 12/28/12 9:21 PM, Peter Alexander wrote:
>>> I'm already assuming 64-bit. What I'm saying is that 64-bit sometimes
>>> isn't even enough (for example in the case of a permutations range). I'm
>>> asking if allowing length to return BigInt would be reasonable.
>>
>> I think it would complicate a lot of things for the benefit of a few
>> cases.
>
> I agree, but the range of permutations will be longer than 2^64 on
> occasion, so what do we do?
>
> * Don't provide .length at all
> * Provide it as size_t, and assert on overflow
> * Provide it as size_t, and silently overflow

I'd say give it a different name, i.e. bigLength.

Andrei


More information about the Digitalmars-d mailing list