From c12cfe83b72c8dab2bf0779acf906ce8ea0373d3 Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Wed, 9 Mar 2022 15:32:33 -0500 Subject: [PATCH] AK: Allow creating a Vector from any Span of the same underlying type This allows, for example, to create a Vector from a subset of another Vector. --- AK/Vector.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/AK/Vector.h b/AK/Vector.h index 9c81689d804..0f6bef51794 100644 --- a/AK/Vector.h +++ b/AK/Vector.h @@ -91,6 +91,13 @@ public: m_size = other.size(); } + explicit Vector(Span other) requires(!IsLvalueReference) + { + ensure_capacity(other.size()); + TypedTransfer::copy(data(), other.data(), other.size()); + m_size = other.size(); + } + template Vector(Vector const& other) {