From 98fdf5ad490a21a4858ed807eaa254c3b1730f15 Mon Sep 17 00:00:00 2001 From: ykiko Date: Thu, 6 Jun 2024 13:09:04 +0800 Subject: [PATCH] Fix resize. --- include/pocketpy/common/vector.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/pocketpy/common/vector.hpp b/include/pocketpy/common/vector.hpp index dc466200..765f2d8e 100644 --- a/include/pocketpy/common/vector.hpp +++ b/include/pocketpy/common/vector.hpp @@ -203,6 +203,7 @@ struct vector { void resize(int size) { reserve(size); + std::uninitialized_default_construct_n(_data + _size, size - _size); _size = size; } @@ -230,7 +231,7 @@ struct vector { uninitialized_copy_n(begin, n, _data + _size); } - void insert(T* it, const T& t) { + void insert(const T* it, const T& t) { assert(it >= begin() && it <= end()); int pos = it - begin(); if(_size == _capacity) {