diff options
author | Ben Maxwell <macdue@dueutil.tech> | 2022-04-02 02:23:33 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-04-02 21:50:41 +0200 |
commit | 0f2c1f804e9dbe28ce01d6e0e11090b7e6473ac0 (patch) | |
tree | 9b4294ec2d2c86879985145075a06240318bbf98 /AK | |
parent | 77add584fa8a69b262738f0b1a5697fbde306ae4 (diff) | |
download | serenity-0f2c1f804e9dbe28ce01d6e0e11090b7e6473ac0.zip |
AK: Add last() utility function to Span
Diffstat (limited to 'AK')
-rw-r--r-- | AK/Span.h | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -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); |