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]

vector<T>::iterator


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?

Thanks, Thomas.



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