From 0c61712f2bdad1a05e28a3339ec945167ec10e85 Mon Sep 17 00:00:00 2001 From: Emil-Jarosz Date: Tue, 13 Oct 2020 17:41:30 +0100 Subject: [PATCH] Fix bug in gp::vector::reserve The bug was causing elements to be shifted forward each time the vector reallocates. --- include/gp/vector.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/gp/vector.hpp b/include/gp/vector.hpp index 2ea73f2..b96dfa5 100644 --- a/include/gp/vector.hpp +++ b/include/gp/vector.hpp @@ -131,7 +131,7 @@ namespace gp{ if(T* new_ary = (T*)alloc.get().allocate(new_data_size); new_ary) { auto new_it = new_ary; for(auto& elem : *this) { - new(++new_it) T(gp::move(elem)); + new(new_it++) T(gp::move(elem)); } if(ary != nullptr) gp_config::assertion(alloc.get().deallocate(ary), "failed to deallocate old range"); @@ -258,4 +258,4 @@ namespace gp{ return gp::buffer{(T*)ary, (T*)ary+sz}; } }; -} \ No newline at end of file +}