title: vector.insert doesn't resize vector?
body: <p>i'm trying to create a function that takes in a vector by reference and if it sees a vector entry 2, it would take delete the entry and replace it with 4 copies of 5. </p>
  
  <p>so if the vector is 222 (then it is size n = 3), i want 555555555555 as the new vector  </p>
  
  <p>however, it only works properly for the first few, when the index is &lt; n. </p>
  
  <p>so right now, it would change vector a to be 555522
  any ideas how to make the vector resize? </p>
  
  <pre><code>void replace2 (vector &lt;int&gt;* a, int n){
  
    for (int i = 0; i &lt; n; ++i){
      if ((*a)[i] == 2){
        (*a).erase((*a).begin() + i);
        for(int j = 0; j &lt; 4; ++j){
        (*a).insert((*a).begin() + i, 5);
              }
          }
        }
  
  }
  </code></pre>