Removing part from a vector of sets

Hello, I was helped earlier, and I was hoping I could be helped again.

I have a vector of sets, which I am removing any element which contains a certain value. For example, if I was looking for 2:
[0] 1 2 3
[1] 4 5 6
After the program was run, I would be left with just [0]4 5 6.

This is the code I have been using

1
2
3
auto iter = std::remove_if( clauseVector.begin(), clauseVector.end(),[propagator] ( const std::set<int>& i ){ 
  return i.find(propagator) != i.end() ; } ) ;
clauseVector.erase( iter, clauseVector.end() ) ;


I want to know, is there any way I can tweak this code so that it only removes one part of the set rather than the whole thing. For example with above example, I would be left with

[0] 1 3
[1] 4 5 6
It would no longer be a remove_if, since you're not removing any vector elements. It's just a for_each:

std::for_each(v.begin(), v.end(), [&](std::set<int>& s){s.erase(propagator);});
Perfect! You wonderful human being
..actually, a for loop is even simpler:

1
2
for(auto& s : clauseVector)
    s.erase(propagator);
I have yet to see any for_each statement that was not simplified by a regular for loop.
Topic archived. No new replies allowed.