From 918e838c1bacf7939cf82adba08a82e46600c526 Mon Sep 17 00:00:00 2001 From: ZhuangYumin Date: Mon, 26 Feb 2024 00:36:39 +0000 Subject: [PATCH] fix some small bug in clear --- vector/src/vector.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vector/src/vector.hpp b/vector/src/vector.hpp index 692261c..c4d42d0 100644 --- a/vector/src/vector.hpp +++ b/vector/src/vector.hpp @@ -360,14 +360,14 @@ class vector { void clear() { if (raw_beg != nullptr) { for (size_t i = 0; i < current_length; ++i) { - alloc.destroy(raw_beg + i); + std::allocator_traits::destroy(alloc, raw_beg + i); } - current_length = 0; alloc.deallocate(raw_beg, allocated_length); } raw_beg = alloc.allocate(1); raw_end = raw_beg; allocated_length = 1; + current_length = 0; } /** * inserts value before pos