title: c++ lambda remove even numbers
body: <p>Im learning the C++ lambda functions, this likely easy problem is giving me some issues.</p>
  
  <p>I have a vector with some integers in it. I am trying to remove all of the even numbers.</p>
  
  <p>I currently have it removing the even numbers, but when I print the contents of the vector, I am left with some repeated data still in the vector at the end.</p>
  
  <pre><code>int main()
  {
    std::vector&lt;int&gt; v1 = {0,1,1,2,3,5,8,13,21,55,89};
  
    for (const auto &amp;i : v1) std::cout&lt;&lt; i &lt;&lt; " ";
    std::cout&lt;&lt;std::endl; 
  
    v1.erase(std::remove_if(v1.begin(), v1.end(), [](int i)
         { return (i % 2) == 0; }));
  
    for (const auto &amp;i : v1) std::cout&lt;&lt; i &lt;&lt; " ";
  }
  </code></pre>
  
  <p>OUTPUT:</p>
  
  <pre><code>0 1 1 2 3 5 8 13 21 55 89 
  1 1 3 5 13 21 55 89 55 89
  </code></pre>
  
  <p>I want the output on the 2nd line to be:</p>
  
  <pre><code>1 1 3 5 13 21 55 89
  </code></pre>
  
  <p>EDIT</p>
  
  <p>Thanks Everyone. I was using the wrong version of erase (feel very dumb now). Here is the correct code:</p>
  
  <pre><code>int main()
  {
    std::vector&lt;int&gt; v1 = {0,1,1,2,3,5,8,13,21,55,89};
  
    for (const auto &amp;i : v1) std::cout&lt;&lt; i &lt;&lt; " ";
    std::cout&lt;&lt;std::endl; 
  
    v1.erase(std::remove_if(v1.begin(), v1.end(), [](int i)
         { return (i % 2) == 0; }), v1.end());
  
    for (const auto &amp;i : v1) std::cout&lt;&lt; i &lt;&lt; " ";
  }
  </code></pre>