diff options
Diffstat (limited to 'src/dynamic-array.hpp')
| -rw-r--r-- | src/dynamic-array.hpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/dynamic-array.hpp b/src/dynamic-array.hpp index d35e5e2..039dcd0 100644 --- a/src/dynamic-array.hpp +++ b/src/dynamic-array.hpp @@ -208,8 +208,9 @@ template <typename T> inline void DynArray<T>::Resize(int64_t count) { int64_t beforeCount = this->elementCount; if IS_DESTRUCTIBLE(T) { if (beforeCount > count) { - for (int64_t i = beforeCount; i > count; --i) { - reinterpret_cast<T *>(this->ptr + (i * sizeof(T)))->~T(); + for (int64_t i = beforeCount - 1; i >= count; --i) { + T *ptr = reinterpret_cast<T *>(this->ptr + (i * sizeof(T))); + ptr->~T(); } } } |
