mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 09:24:57 +00:00
AK: Simplify Array::back()
by checking for Size > 0
We do not want `Array::max()` to be used here at all - we know the size at compile-time, after all.
This commit is contained in:
parent
65df30d00c
commit
bc36e39d07
1 changed files with 2 additions and 2 deletions
|
@ -35,8 +35,8 @@ struct Array {
|
|||
[[nodiscard]] constexpr T const& front() const { return at(0); }
|
||||
[[nodiscard]] constexpr T& front() { return at(0); }
|
||||
|
||||
[[nodiscard]] constexpr T const& back() const { return at(max(1, size()) - 1); }
|
||||
[[nodiscard]] constexpr T& back() { return at(max(1, size()) - 1); }
|
||||
[[nodiscard]] constexpr T const& back() const requires(Size > 0) { return at(Size - 1); }
|
||||
[[nodiscard]] constexpr T& back() requires(Size > 0) { return at(Size - 1); }
|
||||
|
||||
[[nodiscard]] constexpr bool is_empty() const { return size() == 0; }
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue