Deleting from Set while iterating

Revision en1, by luka25, 2016-06-17 19:02:45

I just tried to delete some members from set while iterating with this code:

while(*it<=b){ if(*it!=x){m[*it]=x;s.erase(it);} else it++; }

I found out the right one was this, but can't figure out why

while(*it<=b){ if(*it!=x){m[*it]=x;s.erase(it++);} else it++; }

could anybody explain why it++ instead of it please?

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English luka25 2016-06-17 19:02:45 386 Initial revision (published)