Skip to content

Commit

Permalink
Make Array<T>::set_count ensure the count and calls destructors prope…
Browse files Browse the repository at this point in the history
…rly (#139)
waldnercharles authored Nov 10, 2023
1 parent 43a6e96 commit 8fc0e72
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions include/cute_array.h
Original file line number Diff line number Diff line change
@@ -508,12 +508,12 @@ template <typename T>
void Array<T>::set_count(int count)
{
CF_ARRAY_ENSURE_CAPACITY(count);
if (count > m_count) {
for (int i = count; i < m_count; ++i) {
if (m_count < count) {
for (int i = m_count; i < count; ++i) {
CF_PLACEMENT_NEW(m_ptr + i) T();
}
} else {
for (int i = m_count; i < count; ++i) {
for (int i = count; i < m_count; ++i) {
m_ptr[i].~T();
}
}

0 comments on commit 8fc0e72

Please sign in to comment.