C++, Removing an element from a pair, inside a function
<p>I am using C++, I have a vector of paired variables, for which the first element is a vector and the second element is an integer.  My problem is that I am trying to remove certain elements from this vector, and can't seem to get it to work!</p>

<p>The code is shown below, and everything is working as I'd expect up to the line:</p>

<pre><code>vec1.erase(i);
</code></pre>

<p>as I can cout some other relevant variables from the vector to the screen, and they are correct.</p>

<p>compareVecs is just an element of this class that compares some variables.</p>

<pre><code>void myCode::PairRemoval(vector&lt;myTypeDef&gt; &amp;vec1, const vector&lt;myTypeDef&gt; &amp;vec2, double conditionMax) {
  bool condition=false;
  for (unsigned int i=0; i&lt;vec1.size(); i++){
    for (unsigned int j=0; j&lt;vec2.size(); j++){
      if (vec1[i].first.compareVecs(vec2[j].first) &lt;= conditionMax) {
    condition = true;
       break;
      }
     }  
    if (condition) {
      vec1.erase(i);
      cout&lt;&lt;"removed"&lt;&lt;endl;
    } 
  }
}
</code></pre>

<p>I hope to remove the pair from this vector, if the condition is met.</p>

<p>Thanks in advance for any help!</p>
