|
@@ -36,6 +36,8 @@
|
|
|
#include "core/sort_array.h"
|
|
|
#include "core/vector.h"
|
|
|
|
|
|
+#include <type_traits>
|
|
|
+
|
|
|
template <class T, class U = uint32_t, bool force_trivial = false>
|
|
|
class LocalVector {
|
|
|
private:
|
|
@@ -63,7 +65,7 @@ public:
|
|
|
CRASH_COND_MSG(!data, "Out of memory");
|
|
|
}
|
|
|
|
|
|
- if (!__has_trivial_constructor(T) && !force_trivial) {
|
|
|
+ if (!std::is_trivially_constructible<T>::value && !force_trivial) {
|
|
|
memnew_placement(&data[count++], T(p_elem));
|
|
|
} else {
|
|
|
data[count++] = p_elem;
|
|
@@ -76,7 +78,7 @@ public:
|
|
|
for (U i = p_index; i < count; i++) {
|
|
|
data[i] = data[i + 1];
|
|
|
}
|
|
|
- if (!__has_trivial_destructor(T) && !force_trivial) {
|
|
|
+ if (!std::is_trivially_destructible<T>::value && !force_trivial) {
|
|
|
data[count].~T();
|
|
|
}
|
|
|
}
|
|
@@ -89,7 +91,7 @@ public:
|
|
|
if (count > p_index) {
|
|
|
data[p_index] = data[count];
|
|
|
}
|
|
|
- if (!__has_trivial_destructor(T) && !force_trivial) {
|
|
|
+ if (!std::is_trivially_destructible<T>::value && !force_trivial) {
|
|
|
data[count].~T();
|
|
|
}
|
|
|
}
|
|
@@ -129,7 +131,7 @@ public:
|
|
|
_FORCE_INLINE_ U size() const { return count; }
|
|
|
void resize(U p_size) {
|
|
|
if (p_size < count) {
|
|
|
- if (!__has_trivial_destructor(T) && !force_trivial) {
|
|
|
+ if (!std::is_trivially_destructible<T>::value && !force_trivial) {
|
|
|
for (U i = p_size; i < count; i++) {
|
|
|
data[i].~T();
|
|
|
}
|
|
@@ -146,7 +148,7 @@ public:
|
|
|
data = (T *)memrealloc(data, capacity * sizeof(T));
|
|
|
CRASH_COND_MSG(!data, "Out of memory");
|
|
|
}
|
|
|
- if (!__has_trivial_constructor(T) && !force_trivial) {
|
|
|
+ if (!std::is_trivially_constructible<T>::value && !force_trivial) {
|
|
|
for (U i = count; i < p_size; i++) {
|
|
|
memnew_placement(&data[i], T);
|
|
|
}
|