title: Pass additional arguments to remove_if
body: <p>I would like to remove elements from a vector using <code>remove_if</code> function but limiting the erasing to N elements.</p>
  
  <p>Example:</p>
  
  <pre><code>// predicate function that determines if a value is an odd number.
  bool IsOdd (int i) {
  
    if (we deleted more than deleteLimit)
      return false;
  
    return ((i%2)==1);
  }
  
  
  void otherFunc(){
    int deleteLimit = 10;
  
    // remove odd numbers:                       
    std::vector&lt;int&gt;::iterator newEnd =
    std::remove_if (myints.begin(), myints.end(), IsOdd (how to pass deleteLimit?) );
  }
  </code></pre>
  
  <p>I need that <code>IsOdd</code> predicate stores how many elements it has removed and how many we want to delete.
  The only way is to use a global variable? Like this:</p>
  
  <pre><code>int deleteLimit = 10;
  int removedSoFar = 0;
  bool IsOdd (int i) {
  
    if (deleteLimit &lt; removedSoFar)
      return false;
  
    if (i%2==1) {
      removedSoFar++
      return true;
    }
  
    return false;
  
  }
  remove_if ...
  </code></pre>