Thomas Kunert
Wed Jul 30 14:59:00 GMT 2003

Currently, vector<T>::iterator is defined as some class type. 
I'd like to give some arguments for using T* instead.

The main advantage I see is speed of the produced code. Sure, for an 
flawlessly optimizing compiler, the resulting code should be identical. 
But real world compilers, including GCC, have flaws and hence may produce
worse code when using a class type. Especially for unoptimized compilations,
the resulting code is very different. And, of course, the speed even of
unoptimized code is important.

The next advantage is simpler code in the library itself, which simplifies
bug hunting in the library as well as in user code.

The only disadvantage I see it that T* allows the user to write non-portable
code. This is not really a problem, because such code will be found immediately
and fixed easily if necessary.

Am I missing something?


More information about the Libstdc++ mailing list