memmove
is a lowlevel function for copying bytes. This means that the value of an array of bytes is copied to another array. This is fine for POD data, but not for anything else. The reason is that classes can have a copy constructor, which isn't called by memmove and classes can have extra data like a vpointer for calling virtual member-functions.
The easiest solution for you is to replace memmove
with std::copy
for (#include <algorithm>
) which copies entries instead of bytes:
std::copy(arr_ptr, arr_ptr + old_capacity, tmp_ptr);