reducing needless normal_iterator usage in vector
Theodore Papadopoulo
Theodore.Papadopoulo@sophia.inria.fr
Tue Jul 2 10:16:00 GMT 2002
phil@jaj.com said:
> The reason is simply because that's how the code is in the HP/SGI
> codebase. But they used raw pointers as their iterator typedef; typing
> "begin()" was simply clearer code. Since we use a wrapper class for
> type safety, there can be tiny performance hits, slowly accumulating.
> For simple uses, the clarity doesn't seem to be worth the risk of
> extra code, especially since "_M_start" is just as clear as "begin()".
> Replacing simple expressions like "begin() + n" with "_M_start + n"
> skips the normal_iterator ctor and the normal_iterator's overloaded
> ops, and gets right to the pointer arithmetic that we eventually do
> anyway.
I believe the only reason is for abstraction. If someone, one day,
redefine normal_iterator to be something else than a pointer, he will
not have to re-examinate all the vector code but just implement a
normal_iterator class that provides the relevant operations.
Theo.
--------------------------------------------------------------------
Theodore Papadopoulo
Email: Theodore.Papadopoulo@sophia.inria.fr Tel: (33) 04 92 38 76 01
--------------------------------------------------------------------
More information about the Libstdc++
mailing list