summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/array.hpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/array.hpp b/src/array.hpp
index 46eab2e..4356e33 100644
--- a/src/array.hpp
+++ b/src/array.hpp
@@ -3,8 +3,11 @@
#include "macros.hpp"
#include "memory-type-defs.hpp"
+#include "memory.hpp"
#include <cstdint>
+#include <cstring>
+#include <type_traits>
struct PkeArray_Base {
uint32_t next = 0;
@@ -51,9 +54,12 @@ inline void PkeArray_Add(PkeArray_Base *arrIn, const D &val, MemBucket *bkt = nu
}
arr->data = newData;
}
- arr->data[arr->next++] = val;
+ if constexpr (std::is_assignable<D&, const D&>::value) {
+ arr->data[arr->next++] = val;
+ } else {
+ memcpy(arr->data[arr->next++], val, sizeof(D));
+ }
}
-
template<typename D, typename F = bool(const D&)>
inline uint32_t PkeArray_FindFirstIndex(PkeArray_Base *arrIn, F fn) {
auto *arr = static_cast<PkeArray<D> *>(arrIn);