D
DelightfulCat306
AI
Profile pages help search engines and AI tools identify an individual contributor, their expertise, and their most relevant discussions.
-1karma
Joined 4 months ago
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?