It finally imports somewhat

This commit is contained in:
Dynamitos
2024-05-01 19:05:48 +02:00
parent 2c1669aab4
commit dfcfc2bb1e
19 changed files with 108 additions and 84 deletions
+4 -4
View File
@@ -632,13 +632,14 @@ private:
}
else
{
allocated = calculateGrowth(newSize);
// The array is not big enough, so we make a new one
T *newData = allocateArray(newSize);
T *newData = allocateArray(allocated);
if constexpr (std::is_integral_v<T> || std::is_floating_point_v<T>)
{
std::memcpy(newData, _data, sizeof(T) * arraySize);
std::memset(&newData[arraySize], 0, sizeof(T) * (newSize - arraySize));
std::memset(&newData[arraySize], 0, sizeof(T) * (allocated - arraySize));
}
else
{
@@ -648,14 +649,13 @@ private:
newData[i] = std::forward<Type>(_data[i]);
}
// As well as default initialize the others
for (size_type i = arraySize; i < newSize; ++i)
for (size_type i = arraySize; i < allocated; ++i)
{
std::allocator_traits<allocator_type>::construct(allocator, &newData[i], value);
}
}
deallocateArray(_data, allocated);
arraySize = newSize;
allocated = newSize;
_data = newData;
}
}