From c022b6d74ec19806050a202901fe8a6120102eea Mon Sep 17 00:00:00 2001 From: Ali Mohammad Pur Date: Tue, 25 May 2021 16:54:04 +0430 Subject: [PATCH] AK: Add a way to slice from the end of a span --- AK/Span.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/AK/Span.h b/AK/Span.h index aafe0ae005d..7664daf723c 100644 --- a/AK/Span.h +++ b/AK/Span.h @@ -128,6 +128,11 @@ public: VERIFY(start <= size()); return { this->m_values + start, size() - start }; } + [[nodiscard]] ALWAYS_INLINE constexpr Span slice_from_end(size_t count) const + { + VERIFY(count <= size()); + return { this->m_values + size() - count, count }; + } [[nodiscard]] ALWAYS_INLINE constexpr Span trim(size_t length) const {