title: How can I fill a vector with iterators of a different type?
body: <p>I have many examples of the following code:</p>
  
  <pre><code>struct foo1
  {
      foo1(int ii = 0, int jj = 0)
      {
          this-&gt;ii = ii;
          this-&gt;jj = jj;
      }
  
      int ii;
      int jj;
  };
  
  struct foo2
  {
      foo2()
      {
      }
  
      foo2(const foo1&amp; f)
      {
          this-&gt;f = f;
      }
  
      foo1 f;
  };
  typedef std::vector&lt; foo2 &gt; foo_v;
  
  typedef std::set&lt; int &gt; bar_s;
  
  bar_s barSet;
  barSet.insert(1); barSet.insert(2); barSet.insert(3);
  barSet.insert(4); barSet.insert(5); barSet.insert(6);
  
  ...
  
  foo_v fooVec;
  for (bar_s::iterator b = barSet.begin(); b != barSet.end(); ++b)
      fooVec.push_back(foo2(*b));
  </code></pre>
  
  <p><strong>How can I improve the code where it's filling a new vector of foo2?</strong></p>
  
  <p>I was thinking something along the lines of:</p>
  
  <pre><code>std::remove_copy_if(barSet.begin(), barSet.end(), 
                      std::back_inserter(fooVec), ...)
  </code></pre>
  
  <p>but I'm struggling to find a way to bind the <code>int</code> type to new instances of the <code>foo2</code> struct.</p>
  
  <hr>
  
  <p>Note:</p>
  
  <pre><code>std::copy(barSet.begin(), barSet.end(), std::back_inserter(fooVec));
  </code></pre>
  
  <p>gives me the following error:</p>
  
  <p><em>Error  1   error C2679: binary '=' : no operator found which takes a right-hand operand of type 'int' (or there is no acceptable conversion)</em></p>