#pragma once #include class hkArrayUtil { public: template static HK_FORCE_INLINE void construct(T* t, int n); template static HK_FORCE_INLINE void constructWithCopy(T* t, int n, const T& tcopy); template static HK_FORCE_INLINE void constructWithArray(T* t, int n, const T* tcopy); template static HK_FORCE_INLINE void destruct(T* t, int n); static hkResult _reserve(hkMemoryAllocator& a, void*, int reqElem, int sizeElem); static void _reserveMore(hkMemoryAllocator& a, void* array, int sizeElem); static void _reduce(hkMemoryAllocator& a, void* array, int sizeElem, char* inplaceMem, int requestedCapacity); }; template inline void hkArrayUtil::construct(T* t, int n) { for (int i = 0; i < n; ++i) { ::new (static_cast(t + i)) T; } } template inline void hkArrayUtil::constructWithCopy(T* t, int n, const T& tcopy) { for (int i = 0; i < n; ++i) { ::new (static_cast(t + i)) T(tcopy); } } template inline void hkArrayUtil::constructWithArray(T* t, int n, const T* tcopy) { for (int i = 0; i < n; ++i) { ::new (static_cast(t + i)) T(tcopy[i]); } } template inline void hkArrayUtil::destruct(T* t, int n) { for (int i = n - 1; i >= 0; --i) { static_cast(t)[i].~T(); } }