From 668204041b92661e73d16ae37359b4854cdd9e76 Mon Sep 17 00:00:00 2001 From: MacDue Date: Mon, 9 Jan 2023 23:30:12 +0000 Subject: [PATCH] AK: Add Span::first() The missing sibling to Span::last()! --- AK/Span.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/AK/Span.h b/AK/Span.h index 383d2ae434..79798c1527 100644 --- a/AK/Span.h +++ b/AK/Span.h @@ -212,6 +212,16 @@ public: return this->m_values[index]; } + [[nodiscard]] ALWAYS_INLINE constexpr T const& first() const + { + return this->at(0); + } + + [[nodiscard]] ALWAYS_INLINE constexpr T& first() + { + return this->at(0); + } + [[nodiscard]] ALWAYS_INLINE constexpr T const& last() const { return this->at(this->size() - 1);