title: Correct way to invoke remove_if
body: <p>In the following sample code <code>remove_if</code> is supposed to delete all even numbers but it is not working as I expect.  I am obviously doing something wrong since the output continues to show some even numbers, towards the end.</p>
  <pre><code>#include &lt;iostream&gt;
  #include &lt;vector&gt;
  #include &lt;algorithm&gt;
  using namespace std;
  
  bool
  myCond(int i) { return i % 2 == 0; }
  
  
  int
  main ()
  {
    vector&lt;int&gt; myVector = {11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 22};
    
    remove_if(myVector.begin(), myVector.end(), myCond);
    
    for(int i : myVector) cout &lt;&lt; i &lt;&lt; &quot; &quot;;
    cout &lt;&lt; endl;
    return 0;
  }
  </code></pre>
  <hr />
  <p>output 11 13 15 17 19 16 17 18 19 20 22</p>