Witam mam problem z usuwaniem elementów z listy :
Debug Assertion Failed!
//…
Expression: list iterator not incrementable
I strzałka pokazuje mi na kod w stdthrow.cpp:
_CRTIMP2_PURE void __CLRCALL_PURE_OR_CDECL _Debug_message(const wchar_t *message, const wchar_t *file, unsigned int line)
{ // report error and die
if(::_CrtDbgReportW(_CRT_ASSERT, file, line, NULL, message)==1)
{
-> ::_CrtDbgBreak();
}
}
Mój kod:
list<CIstota*>::iterator iter;
for(iter = lista.begin();iter!=lista.end();++iter)
{
if((*iter)->f_get_stan_zycia()==false)
{
delete *iter;
iter=lista.erase(iter);
}
}
Zauważyłem ,że ten kod wywoływany w pętli kilka razy działa poprawnie a dopiero po jakimś czasie wywala to co napisałem powyżej.