mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-11 05:25:32 +03:00
AK: Allow copying a Vector from a Vector with different inline capacity
This commit is contained in:
parent
4f11528a65
commit
6dec88c7fa
Notes:
sideshowbarker
2024-07-19 10:23:14 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/6dec88c7fa9
18
AK/Vector.h
18
AK/Vector.h
@ -146,6 +146,14 @@ public:
|
|||||||
m_size = other.size();
|
m_size = other.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<int other_inline_capacity>
|
||||||
|
Vector(const Vector<T, other_inline_capacity>& other)
|
||||||
|
{
|
||||||
|
ensure_capacity(other.size());
|
||||||
|
TypedTransfer<T>::copy(data(), other.data(), other.size());
|
||||||
|
m_size = other.size();
|
||||||
|
}
|
||||||
|
|
||||||
// FIXME: What about assigning from a vector with lower inline capacity?
|
// FIXME: What about assigning from a vector with lower inline capacity?
|
||||||
Vector& operator=(Vector&& other)
|
Vector& operator=(Vector&& other)
|
||||||
{
|
{
|
||||||
@ -329,6 +337,16 @@ public:
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<int other_inline_capacity>
|
||||||
|
Vector& operator=(const Vector<T, other_inline_capacity>& other)
|
||||||
|
{
|
||||||
|
clear();
|
||||||
|
ensure_capacity(other.size());
|
||||||
|
TypedTransfer<T>::copy(data(), other.data(), other.size());
|
||||||
|
m_size = other.size();
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
void append(Vector&& other)
|
void append(Vector&& other)
|
||||||
{
|
{
|
||||||
if (is_empty()) {
|
if (is_empty()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user