Witam,
mam prosty problem z metodą erase w std::vector. Zwracany iterator się nie zmienia po usunięciu obiektu z listy.
przykładowy kod:
#include <vector>
int _tmain(int argc, _TCHAR* argv[])
{
std::vector<char *> Lines;
std::vector<char *>::iterator lit;
char * test = "trzydwajeden";
Lines.push_back(test);
lit = Lines.begin();
while(lit != Lines.end())
{
char *str=NULL;
str = *lit;
lit = Lines.erase(lit); //dalej wskazuje na 'trzydwajeden' zamiast na end
//lit = Lines.begin(); //też nie działa
if(str!=NULL)
delete(str);
}
}
patrze jeszcze raz na dokumentacje a tam pisze:
Return value
A random access iterator pointing to the new location of the element that followed the last element erased by the function call, which is the vector end if the operation erased the last element in the sequence.
tylko nie u mnie...
w tym projekcie aplikacja sie wiesza, a w drugim mi wywala asserta
_BLOCK_TYPE_IS_VALID(phead->nBlockUse) - assertion faliure
troche jestem zdezorientowany...