If the element allocated by user not by engine, I think control rights of memory must be given to user, so TArray::Empty() shouldn’t invoke deconstructor of elements.
Besides, the function clear() of **STL **constainer also give the control rights of memory to user, deconstructor of elements are not executed in it. I think the API of STL are pretty standard. so I thing Empty() of UE4 container is imperfect. I hope Epic to improve this API in the future. thx~
Unfortunately this isn’t correct. I use TArrays to hold references to actors all the time and I call Empty() on them pretty often. My actors would be destroyed if the deconstructors were being called on Empty().
It’s not disadvantageous if you don’t want them sorted. Besides… you have to use non-pointer types if you’re using Unreal’s smart pointers. Which is a very common use case and the copy constructor of these smart pointers is quite fast anyway.