mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-03 16:16:43 +00:00
AK: Add span() / bytes() methods to container types.
This commit is contained in:
parent
c42450786c
commit
a922abd9d7
Notes:
sideshowbarker
2024-07-19 04:32:52 +09:00
Author: https://github.com/asynts
Commit: a922abd9d7
Pull-request: https://github.com/SerenityOS/serenity/pull/2903
4 changed files with 24 additions and 5 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue