From 96f1511dbe2e80223732bcbef8068c3d5a330cee Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Fri, 20 Mar 2026 18:08:41 +0100 Subject: kstd/vector: add missing constexpr clang-tidy is not happy about constexpr memory allocation except through the blessed std::allocator::allocate though. So for now we can't use it since it will break the build when linting is enabled. --- libs/kstd/include/kstd/vector | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'libs') diff --git a/libs/kstd/include/kstd/vector b/libs/kstd/include/kstd/vector index a49572b..b2cce0b 100644 --- a/libs/kstd/include/kstd/vector +++ b/libs/kstd/include/kstd/vector @@ -50,7 +50,7 @@ namespace kstd using const_reverse_iterator = std::reverse_iterator; //! Construct a new, empty vector. - vector() noexcept(std::is_nothrow_default_constructible_v) + constexpr vector() noexcept(std::is_nothrow_default_constructible_v) : vector(allocator_type{}) {} @@ -697,10 +697,13 @@ namespace kstd //! Release the memory of this vector. constexpr auto deallocate() { - std::allocator_traits::deallocate(m_allocator, m_data, m_capacity); - m_capacity = 0; - m_size = 0; - m_data = nullptr; + if (m_data) + { + std::allocator_traits::deallocate(m_allocator, m_data, m_capacity); + m_capacity = 0; + m_size = 0; + m_data = nullptr; + } } //! Destroy a number of elements in this vector. -- cgit v1.2.3