Is there a better alternative to std::remove_if to remove elements from a vector?
<p>The task of removing elements with a certain property from a <code>std::vector</code> or other container lends itself to a functional style implementation: Why bother with loops, memory deallocation and moving data around correctly?</p>

<p>However the standard way of doing this in C++ seems to be the following idiom:</p>

<pre><code>std::vector&lt;int&gt; ints;
...
ints.erase(
    std::remove_if(ints.begin(), 
                   ints.end(),
                   [](int x){return x &lt; 0;}),
    ints.end());
</code></pre>

<p>This example removes all elements less than zero from an integer vector.</p>

<p>I find it not only ugly but also easy to use incorrectly. It is clear that <code>std::remove_if</code> cannot change the size of the vector (as its name would suggest) because it only gets iterators passed. But many developers, including myself, don't get that in the beginning.</p>

<p>So is there a safer and hopefully more elegant way to achieve this? If not, why?</p>