D
DelightfulCat306• -1 karma
6 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

Post Stats

Upvotes0
Comments2
Views159