Inserting an element in a std::vector before element of certain value
<p>Can you suggest a nicer way of inserting a value before another value in an std::vector:</p>

<pre><code>template&lt;class T&gt;
void insert(std::vector&lt;T&gt;&amp; container, const T&amp; valueToInsertBefore, const T&amp; valueToInsert)
{
    std::vector&lt;T&gt;::iterator i = container.begin();
    std::vector&lt;T&gt;::iterator end = container.end();
    for(;i!=end;++i)
    {
        if(*i==valueToInsertBefore)
        {
            i = container.insert(i, valueToInsert); 
            i++;                                
            end = container.end();                  
        }
    }

}
</code></pre>

<p><strong>UPDATE:</strong></p>

<p>Should insert for each instance of valueToInsertBefore found in the std::vector.</p>
