| 295 | // ======= RESIZE ======= |
| 296 | |
| 297 | void vector_basic::resize_impl(fl::size n) { |
| 298 | if (n == mSize) return; |
| 299 | |
| 300 | if (n < mSize) { |
| 301 | // Shrink: destroy excess elements |
| 302 | if (mOps) { |
| 303 | for (fl::size i = n; i < mSize; ++i) { |
| 304 | mOps->destroy(element_ptr(i)); |
| 305 | } |
| 306 | } |
| 307 | mSize = n; |
| 308 | return; |
| 309 | } |
| 310 | |
| 311 | // Grow: ensure capacity and default-construct new elements |
| 312 | ensure_capacity(n); |
| 313 | if (mCapacity < n) return; // allocation failed |
| 314 | |
| 315 | if (mOps) { |
| 316 | if (mOps->default_construct) { |
| 317 | for (fl::size i = mSize; i < n; ++i) { |
| 318 | mOps->default_construct(element_ptr(i)); |
| 319 | } |
| 320 | } else { |
| 321 | // Type has no default constructor — zero-fill as fallback |
| 322 | trivial_default_construct(element_ptr(mSize), n - mSize); |
| 323 | } |
| 324 | } else { |
| 325 | trivial_default_construct(element_ptr(mSize), n - mSize); |
| 326 | } |
| 327 | mSize = n; |
| 328 | } |
| 329 | |
| 330 | void vector_basic::resize_value_impl(fl::size n, const void* value) { |
| 331 | if (n == mSize) return; |