Ranges longer than size_t.max
Peter Alexander
peter.alexander.au at gmail.com
Sat Dec 29 12:38:20 PST 2012
On Saturday, 29 December 2012 at 14:23:09 UTC, Andrei
Alexandrescu wrote:
> 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.
But then the range doesn't have a length, even though it would be
useful to have it in a lot of cases.
How about, have .length, and allow it to dangerously overflow,
but also provide .bigLength, which returns a BigInt for when
people need it?
More information about the Digitalmars-d
mailing list