aboutsummaryrefslogtreecommitdiff
path: root/libs/kstd
diff options
context:
space:
mode:
authorFelix Morgner <felix.morgner@ost.ch>2026-03-20 18:08:41 +0100
committerFelix Morgner <felix.morgner@ost.ch>2026-03-20 18:08:41 +0100
commit96f1511dbe2e80223732bcbef8068c3d5a330cee (patch)
tree11c6b17d47c2eea213dbd90f6137a68a119b64b8 /libs/kstd
parent52bc2d4105ac0d10d10831d470e9d0212dbb2b4d (diff)
downloadteachos-96f1511dbe2e80223732bcbef8068c3d5a330cee.tar.xz
teachos-96f1511dbe2e80223732bcbef8068c3d5a330cee.zip
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.
Diffstat (limited to 'libs/kstd')
-rw-r--r--libs/kstd/include/kstd/vector13
1 files changed, 8 insertions, 5 deletions
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<const_iterator>;
//! Construct a new, empty vector.
- vector() noexcept(std::is_nothrow_default_constructible_v<allocator_type>)
+ constexpr vector() noexcept(std::is_nothrow_default_constructible_v<allocator_type>)
: vector(allocator_type{})
{}
@@ -697,10 +697,13 @@ namespace kstd
//! Release the memory of this vector.
constexpr auto deallocate()
{
- std::allocator_traits<allocator_type>::deallocate(m_allocator, m_data, m_capacity);
- m_capacity = 0;
- m_size = 0;
- m_data = nullptr;
+ if (m_data)
+ {
+ std::allocator_traits<allocator_type>::deallocate(m_allocator, m_data, m_capacity);
+ m_capacity = 0;
+ m_size = 0;
+ m_data = nullptr;
+ }
}
//! Destroy a number of elements in this vector.