mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-09 17:44:56 +09:00
AK: Always do bounds checking in Array::operator[]
This commit is contained in:
parent
b7c66233f6
commit
69d8ad52c4
Notes:
sideshowbarker
2024-07-18 21:53:12 +09:00
Author: https://github.com/awesomekling
Commit: 69d8ad52c4
1 changed files with 4 additions and 4 deletions
|
@ -44,12 +44,12 @@ struct Array {
|
||||||
constexpr const T& at(size_t index) const
|
constexpr const T& at(size_t index) const
|
||||||
{
|
{
|
||||||
VERIFY(index < size());
|
VERIFY(index < size());
|
||||||
return (*this)[index];
|
return __data[index];
|
||||||
}
|
}
|
||||||
constexpr T& at(size_t index)
|
constexpr T& at(size_t index)
|
||||||
{
|
{
|
||||||
VERIFY(index < size());
|
VERIFY(index < size());
|
||||||
return (*this)[index];
|
return __data[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr const T& front() const { return at(0); }
|
constexpr const T& front() const { return at(0); }
|
||||||
|
@ -60,8 +60,8 @@ struct Array {
|
||||||
|
|
||||||
constexpr bool is_empty() const { return size() == 0; }
|
constexpr bool is_empty() const { return size() == 0; }
|
||||||
|
|
||||||
constexpr const T& operator[](size_t index) const { return __data[index]; }
|
constexpr const T& operator[](size_t index) const { return at(index); }
|
||||||
constexpr T& operator[](size_t index) { return __data[index]; }
|
constexpr T& operator[](size_t index) { return at(index); }
|
||||||
|
|
||||||
template<typename T2, size_t Size2>
|
template<typename T2, size_t Size2>
|
||||||
constexpr bool operator==(const Array<T2, Size2>& other) const { return span() == other.span(); }
|
constexpr bool operator==(const Array<T2, Size2>& other) const { return span() == other.span(); }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue