AK: Add last() utility function to Span

This commit is contained in:
Ben Maxwell 2022-04-02 02:23:33 +01:00 committed by Andreas Kling
parent 77add584fa
commit 0f2c1f804e

View file

@ -212,6 +212,16 @@ public:
return this->m_values[index];
}
[[nodiscard]] ALWAYS_INLINE constexpr T const& last() const
{
return this->at(this->size() - 1);
}
[[nodiscard]] ALWAYS_INLINE constexpr T& last()
{
return this->at(this->size() - 1);
}
[[nodiscard]] ALWAYS_INLINE constexpr T const& operator[](size_t index) const
{
return at(index);