C++ / Why Iterators Got It All Wrong

Steven Schveighoffer via Digitalmars-d digitalmars-d at puremagic.com
Tue Aug 29 07:58:09 PDT 2017


On 8/29/17 9:34 AM, jmh530 wrote:
> On Tuesday, 29 August 2017 at 13:23:50 UTC, Steven Schveighoffer wrote:
>>
>> Interesting. It reminds me a bit of cursors for dcollections. In 
>> there, a cursor is a 0 or 1 element range. The one element range 
>> points at an element, the 0 element range points at a border. You can 
>> use cursors to compose ranges.
>>
>> https://github.com/schveiguy/dcollections
>>
> 
> I was thinking this exact same thing when I got to the Element part of it.
> 
> The mach library also makes use of cursors.
> https://github.com/pineapplemachine/mach.d
> 
> I'm not entirely sure how if I grok how the Border thing they are 
> talking about works.

A border points between elements. It's like the end element in a 
standard STL container, it's not really pointing at an element, but one 
past the last element.

It can be handy when specifying ranges. I.e. exclusive or inclusive ranges.

My gut feeling is that the splitting of types between elements and 
borders is too much machinery, but I haven't seen it in practice to make 
a fair judgment.

-Steve


More information about the Digitalmars-d mailing list