 <p>use <code>remove_if</code> found under <code>algorithm</code></p> <p>Given a begin and end iterator along with a predicate, you can remove any element that results in the predicate evaluating to true. I'll include both C++03 and C++11 examples.</p> <p>C++03:</p> <pre><code>#include &lt;algorithm&gt; #include &lt;iostream&gt; #include &lt;iterator&gt; #include &lt;vector&gt; #include &lt;cstdlib&gt; #include &lt;ctime&gt; template &lt;typename T&gt; struct is_equal { T val; is_equal (const T&amp; v) : val (v) { } bool operator() (const T&amp; test) { return (val == test); } }; struct is_odd { bool operator() (int test) { return (test % 2 == 1); } }; template &lt;typename T&gt; std::ostream&amp; operator&lt;&lt; (std::ostream&amp; os, const std::vector &lt;T&gt;&amp; v) { typedef typename std::vector &lt;T&gt;::const_iterator itr; for (itr i = v.begin (); i != v.end (); ++i) os &lt;&lt; *i &lt;&lt; " "; return os; } int main (int argc, char* argv[]) { srand (time (NULL)); std::vector &lt;int&gt; vec (10); // vector has size of 10 std::generate (vec.begin (), vec.end (), rand); // populate with random numbers std::cout &lt;&lt; vec &lt;&lt; std::endl; vec.erase (std::remove_if (vec.begin (), vec.end (), is_odd ()), // removes all odd elements vec.end ()); std::cout &lt;&lt; vec &lt;&lt; std::endl; return 0; } </code></pre> <p>C++11:</p> <pre><code>#include &lt;algorithm&gt; #include &lt;iostream&gt; #include &lt;iterator&gt; #include &lt;numeric&gt; #include &lt;vector&gt; #include &lt;cstdlib&gt; template&lt;typename T&gt; std::ostream&amp; operator&lt;&lt; (std::ostream&amp; os, const std::vector &lt;T&gt;&amp; v) { for (auto i : v) os &lt;&lt; i &lt;&lt; " "; return os; } int main(int argc, char* argv[]) { std::vector &lt;int&gt; vec(10); // vector has size of 10 std::iota (vec.begin(), vec.end(), 1); // populate with [1, 2, 3, ...] std::cout &lt;&lt; vec &lt;&lt; std::endl; vec.erase (std::remove_if (vec.begin(), vec.end(), [](int i){ return (i == 3); }), vec.end ()); std::cout &lt;&lt; vec &lt;&lt; std::endl; return 0; } </code></pre> <p>For any questions on using the STL, I personally consult <a href="http://en.cppreference.com/w/" rel="nofollow">http://en.cppreference.com/w/</a> and <a href="http://www.cplusplus.com/reference/" rel="nofollow">http://www.cplusplus.com/reference/</a></p>