vector<int>::iterator iter = iv.begin(), mid = iv.begin() + iv.size()/2; while (iter != mid) { if (*iter == some_val) { iv.insert(iter, 2 * some_val); // Error, we should update the iter iter = iv.insert(iter, 2 * some_val); ++iter; // Increament to point to the original value } ++iter; // Increment to point to the next value }