title: Check if two vectors are equal
body: <p>How can I check whether the first "n" elements of two vectors are equal or not?</p>
  
  <p>I tried the following:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;vector&gt;
  #include &lt;iterator&gt;
  using namespace std;
  
  typedef vector&lt;double&gt; v_t;
  
  int main(){
      v_t v1,v2;
      int n = 9;
  
      for (int i = 1; i&lt;10; i++){
          v1.push_back(i);
          v2.push_back(i);
      }
      v1.push_back(11);
      v2.push_back(12);
  
      if (v1.begin()+n == v2.begin()+n)
          cout &lt;&lt; "success" &lt;&lt; endl;
      else
          cout &lt;&lt; "failure" &lt;&lt; endl;
  }
  </code></pre>
  
  <p>Why does it print "failure" and not "success"?</p>