Why doesn't std::remove remove the last element of my array
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/6456870/stl-remove-doesnt-work-as-expected">STL remove doesn’t work as expected?</a>  </p>
</blockquote>



<p>Sorry, I'm new to C++11 and iterators. This is supposed to remove all the number 3's in the array, but it doesn't remove the last one. Why?</p>

<pre><code>#include &lt;algorithm&gt;
#include &lt;array&gt;
#include &lt;iostream&gt;

int main() {

   std::array&lt;int, 8&gt; a{{9, 3, 4, 5, 33, 5, 6, 3}};

   int N(3);

   std::remove(a.begin(), a.end(), N);

   for (int i : a) {
      std::cout &lt;&lt; i &lt;&lt; '\n';
   }

}
</code></pre>

<p>I get as output:</p>

<pre><code>{ 9, 4, 5, 33, 5, 6, 6, 3 }
                        ^
                        |
             // the last 3 is still there
</code></pre>
