Insert operations
| 577 | |
| 578 | // Insert operations |
| 579 | iterator insert(const_iterator pos, const T& value) { |
| 580 | fl::size index = pos.mIndex; |
| 581 | ensure_capacity(mSize + 1); |
| 582 | |
| 583 | // Shift elements from pos to end one position to the right |
| 584 | for (fl::size i = mSize; i > index; --i) { |
| 585 | fl::size from_idx = get_index(i - 1); |
| 586 | fl::size to_idx = get_index(i); |
| 587 | new (&mData[to_idx]) T(fl::move(mData[from_idx])); |
| 588 | mData[from_idx].~T(); |
| 589 | } |
| 590 | |
| 591 | // Insert new element |
| 592 | fl::size insert_idx = get_index(index); |
| 593 | new (&mData[insert_idx]) T(value); |
| 594 | ++mSize; |
| 595 | |
| 596 | return iterator(this, index); |
| 597 | } |
| 598 | |
| 599 | iterator insert(const_iterator pos, T&& value) { |
| 600 | fl::size index = pos.mIndex; |