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]

Re: vector<T>::iterator


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. The requirement of erase() is not to have an iterator of the correct type but to have a pointer pointing into the correct array. Much more common and more difficult to find is the case of invalid iterators obtained from different vectors or from the same vector before a reallocation took place. There have been rumours about adding accurate array range checking to GCC for quite some time, this solves the problem much more complete.

Thanks,
Thomas.


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