I have this code:
set<int>::iterator new_end =
set_difference(set1.begin(), set1.end(),
set2.begin(), set2.end(),
set1.begin());
set1.erase(new_end, set1.end);
It compiles and runs fine in visual studio. However, in a previous question, people stated that a set
's iterators are supposed to be const
. I don't see anything like that in the standard. Can someone tell me where it says that, or if this is well-defined behavior?
If it's not, please provide code that does what I need. Is there a way to do this without creating a temporary set?