"IndexType" for ranges

Peter Alexander peter.alexander.au at gmail.com
Tue Oct 2 09:45:50 PDT 2012


On Tuesday, 2 October 2012 at 16:29:28 UTC, Simen Kjaeraas wrote:
> On 2012-10-02, 18:09, 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?
>
> That not all ranges use it? If the range uses int, short, byte
> (I wonder why they'd do it, though), using size_t will not even
> compile.

That's kind of my point. Unless there's a compelling reason not 
to, I'd suggest we standardise on size_t indexing (and length) 
and avoid this issue altogether.

C++ containers have a size_type typedef. No one uses it.

Let's keep things simple instead of complicating things for the 
sake of unwanted "flexibility".


More information about the Digitalmars-d mailing list