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.
This commit is contained in:
Timothy Flynn 2022-03-09 15:32:33 -05:00 committed by Andreas Kling
parent 5bb00a75f5
commit c12cfe83b7
Notes: sideshowbarker 2024-07-17 17:27:30 +09:00

View file

@ -91,6 +91,13 @@ public:
m_size = other.size();
}
explicit Vector(Span<T const> other) requires(!IsLvalueReference<T>)
{
ensure_capacity(other.size());
TypedTransfer<StorageType>::copy(data(), other.data(), other.size());
m_size = other.size();
}
template<size_t other_inline_capacity>
Vector(Vector<T, other_inline_capacity> const& other)
{