title: Efficient way to filter out elements from std::vector
body: <p>I have ended up to following code in order to filter out some bad elements from an <code>std::vector</code>:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;vector&gt;
  #include &lt;algorithm&gt;
  
  typedef struct mystruct {
      int id;
      std::string name;
  };
  
  int main()
  {        
      std::vector&lt;mystruct&gt; all_items = {{151, "test1"}, {154, "test4"}, {152, "test2"}, {151, "test1"}, {151, "test1"}, {153, "test3"}};
      std::vector&lt;int&gt; bad_ids = {151, 152};
      std::vector&lt;mystruct&gt; filter_items;
  
      for (const auto&amp; item : all_items) {
          if ( std::find(bad_ids.begin(), bad_ids.end(), item.id) != bad_ids.end() ) {
              std::cout &lt;&lt; "id: " &lt;&lt; item.id &lt;&lt; " is bad" &lt;&lt; std::endl;
          } else {
              std::cout &lt;&lt; "id: " &lt;&lt; item.id &lt;&lt; " is good item" &lt;&lt; std::endl;
              filter_items.emplace_back(item);
          }
      }
  
      for (auto f : filter_items) {
          std::cout &lt;&lt; "Good item: " &lt;&lt; f.id &lt;&lt; std::endl;
      }
  }
  </code></pre>
  
  <p>Is there any more efficient way? Can the <code>std::remove_copy_if</code> or Boost be used here and how?</p>