vector<T>::iterator

Gabriel Dos Reis gdr@integrable-solutions.net
Thu Jul 31 10:50:00 GMT 2003


Thomas Kunert <kunert@physik.tu-dresden.de> writes:

| Gabriel Dos Reis wrote:
| > If you can handle French, here is the part of interest to you:
| >   >      }else{
| >   >          _pCoArt.erase(&_pArt);
| >   Il n'y a pas de fonction erase qui prend l'adresse d'une variable
| >   locale. Avec certaines implémentations (dont g++, la version debug de
| >   StlPort, et la version debug des Dinkumware récents), cette ligne ne se
| >   compilera même pas -- erase veut un iterator, non un pointeur. (Dans
| >   certaines implémentations, un itérateur d'un vector est un pointeur,
| >   mais la norme ne l'exige pas, et à mon avis, ce n'est pas un bon choix
| >   dans l'implémentation.)
| 
| This is an insufficient solution to the general problem
| of ensuring valid iterators.

Yes, James and  people favoring typeful programming are aware that
types (and more generally static type checking) are not guarantees
that nothing will go wrong.  However, they help catching the most
obivous errors.  And the above example is one.


| The requirement of erase() is not to have
| an iterator of the correct type but to have a pointer pointing into
| the correct array.

That implies having the right type.

-- Gaby



More information about the Libstdc++ mailing list