From 119c3d1af78efeac7718e805eddc424160969883 Mon Sep 17 00:00:00 2001 From: Richard Thier Date: Tue, 3 Sep 2024 20:16:32 +0200 Subject: [PATCH] fix for VirtualMemList --- VirtualMemList.hpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/VirtualMemList.hpp b/VirtualMemList.hpp index 39a8d9e..e0cd345 100644 --- a/VirtualMemList.hpp +++ b/VirtualMemList.hpp @@ -41,14 +41,19 @@ public: return base[i]; } - /** Vector compatibility: Use insert() if you want the inserted thing as reference too */ VML_INLINE void push_back(T elem) noexcept { - // Smaller solution: base[end++] = elem; + // Smallest solution: + // base[end++] = elem; + + // Non-working, but logically better solution: + // T *value = (T*) alloc(&a, sizeof(T), sizeof(T), 1); + // *value = elem; + + // Longer solution (more correct - but I let it waste a bit of memory) T *value = (T*) alloc(&a, sizeof(T), sizeof(T), 1); - *value = elem; + base[end++] = elem; } - /** Vector compatibility: Use pop() if you want the popped thing out as copy too */ VML_INLINE void pop_back() noexcept { --end; }