| 203 | } |
| 204 | |
| 205 | void vector_basic::erase_range_impl(fl::size first_index, fl::size count) { |
| 206 | if (count == 0 || first_index >= mSize) return; |
| 207 | if (first_index + count > mSize) { |
| 208 | count = mSize - first_index; |
| 209 | } |
| 210 | |
| 211 | fl::size remaining = mSize - first_index - count; |
| 212 | |
| 213 | if (mOps) { |
| 214 | // Destroy erased elements |
| 215 | for (fl::size i = 0; i < count; ++i) { |
| 216 | mOps->destroy(element_ptr(first_index + i)); |
| 217 | } |
| 218 | // Shift remaining elements left one at a time |
| 219 | for (fl::size i = 0; i < remaining; ++i) { |
| 220 | void* dst = element_ptr(first_index + i); |
| 221 | void* src = element_ptr(first_index + count + i); |
| 222 | mOps->move_construct(dst, src); |
| 223 | mOps->destroy(src); |
| 224 | } |
| 225 | } else { |
| 226 | // Trivial: memmove the remaining elements left |
| 227 | if (remaining > 0) { |
| 228 | trivial_move_left(element_ptr(first_index), |
| 229 | element_ptr(first_index + count), |
| 230 | remaining); |
| 231 | } |
| 232 | } |
| 233 | mSize -= count; |
| 234 | } |
| 235 | |
| 236 | // ======= INSERT ======= |
| 237 | |