This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: reducing needless normal_iterator usage in vector
- From: Theodore Papadopoulo <Theodore dot Papadopoulo at sophia dot inria dot fr>
- To: Phil Edwards <phil at jaj dot com>
- Cc: libstdc++ at gcc dot gnu dot org
- Date: Tue, 02 Jul 2002 19:16:41 +0200
- Subject: Re: reducing needless normal_iterator usage in vector
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
--------------------------------------------------------------------