TODO
Timothy Ritchey
tritchey@vne.com
Fri Oct 30 20:49:00 GMT 1998
Kevin Atkinson wrote:
>
> >- fix vector and string to define non-pointer iterator types. Pointers
> > as container iterators are evil.
>
> Could someone explain why this is?
I am not entirely sure, but I suspect it is because you do not have
control over what the increment, decrement, dereference, etc. operators
do - you depend upon the pointer semantics. Instead, these should be
defined specifically for each container class. This is certainly
necessary for things like reverse_iterator, where the normal
increment/decrement operations are reversed. Pointers only work in the
trivial case as iterators. Even though late standards changes made sure
that you could treat iterators LIKE pointers (ie. by using -> on them)
they were never intended to BE pointers.
Someone may have some more concrete reasons why pointers are truly evil,
and not simply a hack until a proper implementation was completed. I
could be entirely wrong here.
Cheers,
tim
More information about the Libstdc++
mailing list