Bounds-guarded erase: no-op if `i >= size()`. Erasing storage_[i] (a unique_ptr) never touches the addresses of surviving BufferRecords, so any Stage still holding a span into a surviving record's bytes stays valid. Callers that also own per-index Stage state must drop the Stage referencing the erased record *before* calling this, since the Stage's span becomes dangling once the record is destroye
| 120 | // the Stage referencing the erased record *before* calling this, since |
| 121 | // the Stage's span becomes dangling once the record is destroyed. |
| 122 | void erase(std::size_t i) { |
| 123 | if (i >= storage_.size()) { |
| 124 | return; |
| 125 | } |
| 126 | storage_.erase(storage_.begin() + static_cast<std::ptrdiff_t>(i)); |
| 127 | } |
| 128 | |
| 129 | private: |
| 130 | std::vector<std::unique_ptr<BufferRecord>> storage_; |