This is the mail archive of the
mailing list for the libstdc++ project.
- From: Thomas Kunert <kunert at physik dot tu-dresden dot de>
- To: libstdc++ at gcc dot gnu dot org
- Date: Wed, 30 Jul 2003 16:59:50 +0200
- Subject: 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?