1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 07:37:35 +00:00

AK: Add span() / bytes() methods to container types.

This commit is contained in:
asynts 2020-07-27 14:15:37 +02:00 committed by Andreas Kling
parent c42450786c
commit a922abd9d7
4 changed files with 24 additions and 5 deletions

View file

@ -29,6 +29,7 @@
#include <AK/Badge.h>
#include <AK/RefCounted.h>
#include <AK/RefPtr.h>
#include <AK/Span.h>
#include <AK/Types.h>
#include <AK/kmalloc.h>
@ -58,6 +59,9 @@ public:
size_t length() const { return m_length; }
const char* characters() const { return &m_inline_buffer[0]; }
ALWAYS_INLINE ReadonlyBytes bytes() const { return { characters(), length() }; }
const char& operator[](size_t i) const
{
ASSERT(i < m_length);