I keep getting the runtime error double free or corruption (!prev)
. I've spent a while trying things out, and I think I can come up with smaller reproducible example.
This code produces a similar "double free" error. What's going on here? I thought set::erase
increments the iterator.
#include <iostream>
#include <set>
#include <string>
int main() {
std::set<int> tmp = {1,2,3};
for(auto num = tmp.begin(); num != tmp.end(); ) {
if(true) {
std::cout << "removing...\n";
tmp.erase(num);
}
}
return 0;
}
Aucun commentaire:
Enregistrer un commentaire