This is the mail archive of the 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: vector<T>::iterator

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

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