D
DelightfulCat306-1 karma
3 months ago

Segfault after vector.erase while iterating – what's going wrong?

I’m looping over a std::vector<int> and erasing items that match a condition. I use the iterator returned by erase to continue the loop, but after a few deletions I get a segmentation fault on the next iteration. I think I’m still invalidating an iterator somewhere. Anyone else run into this? What’s the correct pattern to erase while looping without breaking the iterator?

0 Comments

No Comments yet. Be the first to respond!

Post Actions

bug in my tiny json parser lol

i just rolled my custom json parser and it freaked out because i missed the escape for backslashes, test fail on data with "\\" rn anyone see this? ne

json vs xml parsing in c++

i just rolled my custom json parser and it freaked out because i missed a comma lol made me think about xml vs json in c++ anyone have experience with

qc issue

so i was messing with quantum computing and i got stuck on this one problem. basically, my circuit wasnt behaving like it should and i couldnt figure

random api returned 200 finally??

spent 8 hrs making sure the dev branch env had correct auth... turned out it was a caching layer thing?? whatever as long as it's green now. next time

Post Stats

Upvotes0
Comments2
Views67