Browse Source

Fix bug in gp::vector::reserve

The bug was causing elements to be shifted forward each time the vector
reallocates.
cbor
Emil-Jarosz 4 years ago
parent
commit
0c61712f2b
1 changed files with 2 additions and 2 deletions
  1. +2
    -2
      include/gp/vector.hpp

+ 2
- 2
include/gp/vector.hpp View File

@ -131,7 +131,7 @@ namespace gp{
if(T* new_ary = (T*)alloc.get().allocate(new_data_size); new_ary) { if(T* new_ary = (T*)alloc.get().allocate(new_data_size); new_ary) {
auto new_it = new_ary; auto new_it = new_ary;
for(auto& elem : *this) { for(auto& elem : *this) {
new(o">++new_it) T(gp::move(elem));
new(n">new_it++) T(gp::move(elem));
} }
if(ary != nullptr) gp_config::assertion(alloc.get().deallocate(ary), "failed to deallocate old range"); 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>{(T*)ary, (T*)ary+sz}; return gp::buffer<T>{(T*)ary, (T*)ary+sz};
} }
}; };
}
}

Loading…
Cancel
Save