Iterators Must Go

Michel Fortin michel.fortin at michelf.com
Sat May 9 09:40:34 PDT 2009


On 2009-05-09 10:45:05 -0400, "Steven Schveighoffer" 
<schveiguy at yahoo.com> said:

> STL iterators can be used for more than just iteration.  They also 
> serve  as cursors, or pointers to specific elements.  If you add the 
> ability for  them to check their own bounds, then they become as safe 
> as ranges, and  can be used as general purpose pointers for things like 
> insertion,  deletion, bi-directional traversal, things that ranges can 
> do but are  clumsy at.
> 
> You still have the interchangable-with-pointer concept burned into your 
>  brain :)
> 
> Think more like this:
> 
> for(cursor i = begin; !i.end; i++)

So basically your cursor is a range (so it knows its bounds) with an 
added position pointer.


-- 
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/




More information about the Digitalmars-d mailing list