summaryrefslogtreecommitdiff
path: root/AK
diff options
context:
space:
mode:
authorMacDue <macdue@dueutil.tech>2023-02-05 17:59:03 +0000
committerLinus Groh <mail@linusgroh.de>2023-02-08 19:15:45 +0000
commit8483efb399faa961f26c3ff4273bf424e75a3157 (patch)
treeacdc6969c4b6ed3ff9bb8dcb60ffe603c2e95e74 /AK
parentb1793868b0e76dd39f7343c451178cf05ceca47b (diff)
downloadserenity-8483efb399faa961f26c3ff4273bf424e75a3157.zip
AK: Add ReadonlySpan<T> as an alias for Span<T const>
This is a little clearer than Span<T const> where it looks like it's the T not the underlying array that's const.
Diffstat (limited to 'AK')
-rw-r--r--AK/Forward.h5
-rw-r--r--AK/Span.h6
2 files changed, 9 insertions, 2 deletions
diff --git a/AK/Forward.h b/AK/Forward.h
index e258449ffd..3f67a9fd8a 100644
--- a/AK/Forward.h
+++ b/AK/Forward.h
@@ -61,7 +61,10 @@ struct Array;
template<typename Container, typename ValueType>
class SimpleIterator;
-using ReadonlyBytes = Span<u8 const>;
+template<typename T>
+using ReadonlySpan = Span<T const>;
+
+using ReadonlyBytes = ReadonlySpan<u8>;
using Bytes = Span<u8>;
template<typename T, AK::MemoryOrder DefaultMemoryOrder>
diff --git a/AK/Span.h b/AK/Span.h
index 79798c1527..c4ffe3c9b5 100644
--- a/AK/Span.h
+++ b/AK/Span.h
@@ -271,7 +271,10 @@ struct Traits<Span<T>> : public GenericTraits<Span<T>> {
constexpr static bool is_trivial() { return true; }
};
-using ReadonlyBytes = Span<u8 const>;
+template<typename T>
+using ReadonlySpan = Span<T const>;
+
+using ReadonlyBytes = ReadonlySpan<u8>;
using Bytes = Span<u8>;
}
@@ -279,5 +282,6 @@ using Bytes = Span<u8>;
#if USING_AK_GLOBALLY
using AK::Bytes;
using AK::ReadonlyBytes;
+using AK::ReadonlySpan;
using AK::Span;
#endif