This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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
 --------------------------------------------------------------------



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]