My problem is that when I use erase() on a set<int>, I get a runtime error (windows must close the program, etc.). Chances are it is something obvious. Here is the relevant code:
By extensive testing I have concluded that it is the actual erase function that is causing the error, so it is not an invalidated iterator or some other such error. The answer might possibly have to do with my layered use of iterators and pointers.Code:typedef pair<int,set<int> > Square; typedef vector<Square*> LinePtr; //... for(lt2=0;lt2<3;++lt2) { LinePtr l = getMyl(); for(LinePtr::iterator it=l.begin();it!=l.end();++it) { Square *sp = *it; int lownum = *(ls.begin()); int highnum = *(++ls.begin()); if(sp->second.count(lownum)>0) sp->second.erase(lownum); if(sp->second.count(highnum)>0) sp->second.erase(highnum); } } }
If the answer is not apparent, what possible causes could there be for a runtime error with erase()?