title: Removing elements from vector using remove_if
body: <p>I am trying to remove vector elements using <code>remove_if</code>. But unsuccessfully. What am I doing wrong? </p>
  
  <p>Here's my code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  #include &lt;vector&gt;
  #include &lt;algorithm&gt;
  
  void printme(std::vector&lt;int&gt;&amp; a){
      for(const auto&amp; item: a)
      std::cout &lt;&lt; item &lt;&lt; std::endl;
  }
  
  int main()
  {
      std::vector&lt;int&gt; a {1, 2, 3, 4, 5, 6};
      printme(a);  
      a.erase( (std::remove_if(a.begin(), a.end(), [](const int&amp; x){
          return x == 2;
          }), a.end()));
      printme(a);
  }
  </code></pre>
  
  <p>My output is just:</p>
  
  <blockquote>
    <p>1 2 3 4 5 6 </p>
  </blockquote>
  
  <p>Expected output:</p>
  
  <blockquote>
    <p>1 2 3 4 5 6 1 3 4 5 6 </p>
  </blockquote>