瀏覽代碼

Fix bug in gp::vector::reserve

The bug was causing elements to be shifted forward each time the vector
reallocates.
cbor
Emil-Jarosz 4 年之前
父節點
當前提交
0c61712f2b
共有 1 個檔案被更改,包括 2 行新增2 行删除
  1. +2
    -2
      include/gp/vector.hpp

+ 2
- 2
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(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");
@ -258,4 +258,4 @@ namespace gp{
return gp::buffer<T>{(T*)ary, (T*)ary+sz};
}
};
}
}

Loading…
取消
儲存