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; }