From 8e7dfebf118180174d1b55524158e39634762c79 Mon Sep 17 00:00:00 2001 From: asynts Date: Wed, 12 Aug 2020 21:15:11 +0200 Subject: [PATCH] AK: Add bytes() method to FixedArray. --- AK/FixedArray.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/AK/FixedArray.h b/AK/FixedArray.h index 7e86166746f..a63c57fcb5c 100644 --- a/AK/FixedArray.h +++ b/AK/FixedArray.h @@ -26,6 +26,7 @@ #pragma once +#include #include namespace AK { @@ -33,7 +34,7 @@ namespace AK { template class FixedArray { public: - FixedArray() {} + FixedArray() { } explicit FixedArray(size_t size) : m_size(size) { @@ -86,6 +87,9 @@ public: return m_elements; } + Bytes bytes() { return { data(), size() }; } + ReadonlyBytes bytes() const { return { data(), size() }; } + T& operator[](size_t index) { ASSERT(index < m_size); @@ -138,6 +142,9 @@ public: ConstIterator begin() const { return ConstIterator(*this, 0); } ConstIterator end() const { return ConstIterator(*this, size()); } + operator Bytes() { return bytes(); } + operator ReadonlyBytes() const { return bytes(); } + private: size_t m_size { 0 }; T* m_elements { nullptr };