From df1f8a82ed6e4ada9b807531bd1f6e3c60d7151c Mon Sep 17 00:00:00 2001 From: cyborg1811m Date: Mon, 15 Jan 2024 11:51:23 +0100 Subject: [PATCH] changed all std::destroy --- include/const_vector.hpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/include/const_vector.hpp b/include/const_vector.hpp index e4f317b..feaa1de 100644 --- a/include/const_vector.hpp +++ b/include/const_vector.hpp @@ -108,7 +108,7 @@ namespace cc { [[nodiscard]] constexpr size_type capacity() const noexcept { return _len; } [[nodiscard]] constexpr size_type size() const noexcept { return _size; } - constexpr void clear() { _erase_no_move(std::begin(_arr), std::end(_arr)); } + constexpr void clear() { std::fill(begin(), end(), T()); } constexpr iterator insert(const_iterator pos, const T& value); constexpr iterator insert(const_iterator pos, T&& value); @@ -134,9 +134,6 @@ namespace cc { template constexpr void swap(const_vector& other); - protected: - constexpr inline void _erase_no_move(const_iterator first, const_iterator last) { std::destroy(first, last); } - #ifdef UNIT_TEST friend test_const_vector; #endif @@ -324,8 +321,7 @@ namespace cc { auto distance = std::distance(first, last); if (distance > N) throw std::invalid_argument("Iterator distance in assign surpasses size" + std::to_string(distance) + ">=" + std::to_string(N)); _size = distance; - std::destroy(_arr, _arr + _size); - std::copy(first, last, _arr); + std::copy(first, last, begin()); } template