"IndexType" for ranges
Peter Alexander
peter.alexander.au at gmail.com
Tue Oct 2 09:48:47 PDT 2012
On Tuesday, 2 October 2012 at 16:44:48 UTC, monarch_dodra wrote:
> On Tuesday, 2 October 2012 at 16:09:16 UTC, Peter Alexander
> wrote:
>> On Tuesday, 2 October 2012 at 13:17:45 UTC, monarch_dodra
>> wrote:
>>> If you've ever worked on a template that needs to index a
>>> range, you may have run into this problem: What is the type
>>> you should use to index an RA range?
>>
>> Forgive my ignorance. What's wrong with size_t?
>
> This is what happens when you use size_t:
>
> [snip]
Then don't create ranges that use ushort for indexing and length.
There's no need to.
To be clear, I'm suggesting that all random access ranges should
use size_t, and they will not be random access ranges if they use
anything else. Unless someone can give a compelling reason not to
do this, I cannot see anything but benefits.
More information about the Digitalmars-d
mailing list