Skip to content

Commit

Permalink
AK: Always do bounds checking in Array::operator[]
Browse files Browse the repository at this point in the history
  • Loading branch information
awesomekling committed Feb 27, 2021
1 parent b7c6623 commit 69d8ad5
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions AK/Array.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ struct Array {
constexpr const T& at(size_t index) const
{
VERIFY(index < size());
return (*this)[index];
return __data[index];
}
constexpr T& at(size_t index)
{
VERIFY(index < size());
return (*this)[index];
return __data[index];
}

constexpr const T& front() const { return at(0); }
Expand All @@ -60,8 +60,8 @@ struct Array {

constexpr bool is_empty() const { return size() == 0; }

constexpr const T& operator[](size_t index) const { return __data[index]; }
constexpr T& operator[](size_t index) { return __data[index]; }
constexpr const T& operator[](size_t index) const { return at(index); }
constexpr T& operator[](size_t index) { return at(index); }

template<typename T2, size_t Size2>
constexpr bool operator==(const Array<T2, Size2>& other) const { return span() == other.span(); }
Expand Down

0 comments on commit 69d8ad5

Please sign in to comment.