1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-02-21 22:54:16 +01:00

[util] Add move & copy constructors to small_vector

This commit is contained in:
Robin Kertels 2024-03-13 15:49:01 +01:00 committed by Joshie
parent ab12ffa0da
commit 7de88ff993

View File

@ -13,8 +13,37 @@ namespace dxvk {
small_vector() { }
small_vector (const small_vector&) = delete;
small_vector& operator = (const small_vector&) = delete;
small_vector(const small_vector& other) {
reserve(other.m_size);
for (size_t i = 0; i < other.m_size; i++) {
*ptr(i) = *other.ptr(i);
}
m_size = other.m_size;
};
small_vector& operator = (const small_vector& other) {
for (size_t i = 0; i < m_size; i++)
ptr(i)->~T();
reserve(other.m_size);
for (size_t i = 0; i < other.m_size; i++) {
*ptr(i) = *other.ptr(i);
}
m_size = other.m_size;
};
small_vector(small_vector&& other) {
if (other.m_capacity == N) {
for (size_t i = 0; i < other.m_size; i++) {
u.m_data[i] = std::move(other.u.m_data[i]);
}
} else {
u.m_ptr = other.u.m_ptr;
other.m_capacity = N;
}
m_size = other.m_size;
other.m_size = 0;
}
~small_vector() {
for (size_t i = 0; i < m_size; i++)