mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +00:00
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:
parent
5bb00a75f5
commit
c12cfe83b7
Notes:
sideshowbarker
2024-07-17 17:27:30 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/SerenityOS/serenity/commit/c12cfe83b7 Pull-request: https://github.com/SerenityOS/serenity/pull/12976 Reviewed-by: https://github.com/davidot
1 changed files with 7 additions and 0 deletions
|
@ -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)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue