title: Initialize a iterator with a pointer in C++
body: <p>I am having problems building a library in VC9, but which was previously successfully built in VC6.
  Here is a part of the code:</p>
  
  <pre><code>size_t pos2find;
  pos2find = J; 
  std::vector&lt;size_t&gt;::iterator it(&amp;pos2find);
  </code></pre>
  
  <p>And here is the error:</p>
  
  <pre><code>    error C2664: 'std::_Vector_iterator&lt;_Ty,_Alloc&gt;::_Vector_iterator(const std::_Vector_iterator&lt;_Ty,_Alloc&gt; &amp;)' : cannot convert parameter 1 from 'size_t *' to 'const std::_Vector_iterator&lt;_Ty,_Alloc&gt; &amp;'
      1&gt;        with
      1&gt;        [
      1&gt;            _Ty=size_t,
      1&gt;            _Alloc=std::allocator&lt;size_t&gt;
      1&gt;        ]
      1&gt;        Reason: cannot convert from 'size_t *' to 'const std::_Vector_iterator&lt;_Ty,_Alloc&gt;'
  
  1&gt;        with
  1&gt;        [
  1&gt;            _Ty=size_t,
  1&gt;            _Alloc=std::allocator&lt;size_t&gt;
  1&gt;        ]
  1&gt;        No constructor could take the source type, or constructor overload resolution was ambiguous
  </code></pre>
  
  <p>I appreciate any help.</p>
  
  <p>EDIT:
  The code is from an open source library called "surfit", it is not my code, so i guess it's something that changed in the standard of the vector class.
  The iterator is then used in another std function:</p>
  
  <pre><code>std::vector&lt;size_t&gt;::iterator * ptr_from = fault-&gt;sort_by_first_begin;
  std::vector&lt;size_t&gt;::iterator * ptr;
  ptr = std::lower_bound(ptr_from, 
                 fault-&gt;sort_by_first_end, 
                 it, 
                 ptr_size_t_less);
  </code></pre>
  
  <p>EDIT:
  I think i found a solution. After looking into std::lower_bound() :</p>
  
  <pre><code>template &lt;class ForwardIterator, class T, class Compare&gt;
    ForwardIterator lower_bound ( ForwardIterator first, ForwardIterator last,
                                  const T&amp; value, Compare comp );
  
  Return iterator to lower bound
  Returns an iterator pointing to the first element in the sorted range [first,last) which does not compare less than value. The comparison is done using either operator&lt; for the first version, or comp for the second.
  
  For the function to yield the expected result, the elements in the range shall already be ordered according to the same criterion (operator&lt; or comp).
  </code></pre>
  
  <p>With this i just eliminated the it iterator and used lower_bound(first, last, &amp;pos2find, comp);</p>