summaryrefslogtreecommitdiff
path: root/AK/Span.h
diff options
context:
space:
mode:
authorasynts <asynts@gmail.com>2020-07-26 18:08:40 +0200
committerAndreas Kling <kling@serenityos.org>2020-07-27 19:58:09 +0200
commit7036a9b6f7d7df230b060252cc56f5f9a09eb43b (patch)
tree5c5f692abee73f3aa6130d04bef5d40a94a56beb /AK/Span.h
parent68cf22d580a91885bc97a8ecca8a37eb31237e50 (diff)
downloadserenity-7036a9b6f7d7df230b060252cc56f5f9a09eb43b.zip
AK: Define conversion from Span<T> to Span<const T> correctly.
I accidently wrote `Span<RemoveConst<T>>` when I meant `Span<RemoveConst<T>::Type>`. Changing that wouldn't be enough though, this constructor can only be defined if T is not const, otherwise it would redefine the copy constructor. This can be avoided by overloading the cast operator.
Diffstat (limited to 'AK/Span.h')
-rw-r--r--AK/Span.h10
1 files changed, 5 insertions, 5 deletions
diff --git a/AK/Span.h b/AK/Span.h
index bf46986cd0..e974ce8807 100644
--- a/AK/Span.h
+++ b/AK/Span.h
@@ -52,11 +52,6 @@ public:
, m_size(other.m_size)
{
}
- ALWAYS_INLINE Span(const Span<RemoveConst<T>>& other)
- : m_values(other.m_values)
- , m_size(other.m_size)
- {
- }
ALWAYS_INLINE const T* data() const { return m_values; }
ALWAYS_INLINE T* data() { return m_values; }
@@ -115,6 +110,11 @@ public:
m_values = other.m_values;
}
+ ALWAYS_INLINE operator Span<const T>() const
+ {
+ return { data(), size() };
+ }
+
protected:
T* m_values { nullptr };
size_t m_size { 0 };