From a2e3fea7c7c3efb882e0f48add74857691ef67dc Mon Sep 17 00:00:00 2001 From: Jonathan Bradley Date: Thu, 21 Dec 2023 15:56:40 -0500 Subject: check assignable in PkeArray --- src/array.hpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src') 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 +#include +#include 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::value) { + arr->data[arr->next++] = val; + } else { + memcpy(arr->data[arr->next++], val, sizeof(D)); + } } - template inline uint32_t PkeArray_FindFirstIndex(PkeArray_Base *arrIn, F fn) { auto *arr = static_cast *>(arrIn); -- cgit v1.2.3