From a5f5e45fbd3fde4ea9d4784d3011bee59fc4f9cb Mon Sep 17 00:00:00 2001 From: Patrick Date: Mon, 29 Jul 2024 16:31:03 +0200 Subject: [PATCH] fixed clear() --- include/const_vector.hpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/include/const_vector.hpp b/include/const_vector.hpp index f149c6f..e0c41c5 100644 --- a/include/const_vector.hpp +++ b/include/const_vector.hpp @@ -114,7 +114,7 @@ namespace cc { [[nodiscard]] constexpr size_type capacity() const noexcept { return _len; } [[nodiscard]] constexpr size_type size() const noexcept { return _size; } - constexpr void clear() { std::fill(begin(), end(), T()); } + constexpr void clear(); constexpr iterator insert(const_iterator pos, const T& value); constexpr iterator insert(const_iterator pos, T&& value); @@ -386,6 +386,13 @@ namespace cc { return _arr[pos]; } + template + constexpr void const_vector::clear() + { + std::destroy(begin(), end()); + _size = 0; + } + template constexpr const_vector::iterator const_vector::insert(const_vector::const_iterator pos, const T &value) {