title: STL remove first element that matches a predicate from a vector
body: <p>What is an efficient way to erase the first element in a vector that matches a predicate? I am storing unique values in a vector so I wouldn't want the algorithm to search the whole container. </p>
  
  <p>Currently I am doing:</p>
  
  <pre><code>if ((auto it = std::find_if(container.begin(),container.end(),
      [](Type&amp; elem){ return elem == value;}) != container.end()))
  {
          container.erase(it);
  }
  </code></pre>
  
  <p>Thanks, in advance.</p>