title: How to identify if vector iterator has reached end of vector?
body: <p>I have a vector of integers and I want my iterator to point to my desired number (call it 'test').</p>
  
  <pre><code>vector&lt;int&gt; vec;
  void find(std::vector&lt;int&gt;::iterator iter, int test)
  {
      if((*iter)!=test){ ++iter;}
  }
  </code></pre>
  
  <p>That is sometimes problematic because iter might hit the end of the vector (if 'test' is not in the vector) and I'll run into an error.</p>
  
  <p>Is there anyway I can perform something like</p>
  
  <pre><code>if(iter!=vec.end())
  </code></pre>
  
  <p>and stop the iteration without specifying my vector in the function? Thank you!</p>