Commit ddd90bee authored by Kenton Varda's avatar Kenton Varda

Fix const-correctness of Vector::operator[].

Not sure how this slipped by for so long!
parent 62a493ca
......@@ -162,7 +162,11 @@ public:
}
inline size_t size() const { return size_; }
inline T& operator[](size_t index) const {
inline T& operator[](size_t index) {
KJ_IREQUIRE(index < size_, "Out-of-bounds Array access.");
return ptr[index];
}
inline const T& operator[](size_t index) const {
KJ_IREQUIRE(index < size_, "Out-of-bounds Array access.");
return ptr[index];
}
......@@ -356,7 +360,11 @@ public:
inline size_t size() const { return pos - ptr; }
inline size_t capacity() const { return endPtr - ptr; }
inline T& operator[](size_t index) const {
inline T& operator[](size_t index) {
KJ_IREQUIRE(index < implicitCast<size_t>(pos - ptr), "Out-of-bounds Array access.");
return ptr[index];
}
inline const T& operator[](size_t index) const {
KJ_IREQUIRE(index < implicitCast<size_t>(pos - ptr), "Out-of-bounds Array access.");
return ptr[index];
}
......
......@@ -52,7 +52,8 @@ public:
inline size_t size() const { return builder.size(); }
inline bool empty() const { return size() == 0; }
inline size_t capacity() const { return builder.capacity(); }
inline T& operator[](size_t index) const { return builder[index]; }
inline T& operator[](size_t index) { return builder[index]; }
inline const T& operator[](size_t index) const { return builder[index]; }
inline const T* begin() const { return builder.begin(); }
inline const T* end() const { return builder.end(); }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment