for (Shape *i : shapes) { for (Shape *j : shapes) { if (i != j) { if (check(i,j)){ shapes.erase(remove(shapes.begin(), shapes.end(), i), shapes.end()); this causes an error because it's going to carry on iterating even though i does not exist, my question is how do I cleanly do this? currently I get an error "vector iterator not incrementable"
Can i just exit the second loop and continue in the first one?