diff options
author | asynts <asynts@gmail.com> | 2020-08-12 11:44:20 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-08-15 21:21:18 +0200 |
commit | 78849bbb48120651103fef0882ace6dc38c5c9c8 (patch) | |
tree | ca0ac55c203e52fe1a46e9d77f58646327a40f39 /AK | |
parent | 8e7dfebf118180174d1b55524158e39634762c79 (diff) | |
download | serenity-78849bbb48120651103fef0882ace6dc38c5c9c8.zip |
AK: Add copy_to() and move_to() methods to AK::Span.
Diffstat (limited to 'AK')
-rw-r--r-- | AK/Span.h | 22 |
1 files changed, 22 insertions, 0 deletions
@@ -154,6 +154,28 @@ public: return this->m_values + start; } + ALWAYS_INLINE void copy_to(Span other) const + { + ASSERT(other.size() >= size()); + __builtin_memcpy(other.data(), data(), sizeof(T) * size()); + } + + ALWAYS_INLINE void copy_trimmed_to(Span other) const + { + __builtin_memcpy(other.data(), data(), sizeof(T) * min(size(), other.size())); + } + + ALWAYS_INLINE void move_to(Span other) const + { + ASSERT(other.size() >= size()); + __builtin_memmove(other.data(), data(), sizeof(T) * size()); + } + + ALWAYS_INLINE void move_trimmed_to(Span other) const + { + __builtin_memmove(other.data(), data(), sizeof(T) * min(size(), other.size())); + } + ALWAYS_INLINE const T& at(size_t index) const { ASSERT(index < this->m_size); |