feat(array): add const qualified TSBaseArray::operator[]

This commit is contained in:
fallenoak 2025-12-23 21:03:16 -06:00
parent cf433ff1f3
commit 5cdbd74e01

View file

@ -19,6 +19,7 @@ class TSBaseArray {
// Member functions
T& operator[](uint32_t index);
const T& operator[](uint32_t index) const;
void CheckArrayBounds(uint32_t index) const;
void Constructor();
uint32_t Count() const;
@ -33,6 +34,12 @@ T& TSBaseArray<T>::operator[](uint32_t index) {
return this->m_data[index];
}
template <class T>
const T& TSBaseArray<T>::operator[](uint32_t index) const {
this->CheckArrayBounds(index);
return this->m_data[index];
}
template <class T>
void TSBaseArray<T>::CheckArrayBounds(uint32_t index) const {
if (index < this->Count()) {