fix small vector indexing checks

This commit is contained in:
Ronan Collobert
2025-10-31 11:46:36 -07:00
parent 979abf462b
commit 6343622c67

View File

@@ -302,7 +302,7 @@ class SmallVector {
} }
T& at(int index) { T& at(int index) {
if (index >= size()) { if (index < 0 || index >= size()) {
throw std::out_of_range("SmallVector out of range."); throw std::out_of_range("SmallVector out of range.");
} }
return begin_[index]; return begin_[index];
@@ -312,7 +312,7 @@ class SmallVector {
} }
T& operator[](int index) { T& operator[](int index) {
assert(size() > index); assert(index >= 0 && size() > index);
return begin_[index]; return begin_[index];
} }
const T& operator[](int index) const { const T& operator[](int index) const {