From e329280a13aa6c1147830aede2634be42482f783 Mon Sep 17 00:00:00 2001 From: Elvir Crncevic Date: Fri, 5 Jul 2024 11:18:02 +0200 Subject: [PATCH] AK: Inline statement in requires --- AK/Vector.h | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/AK/Vector.h b/AK/Vector.h index 4cc87fb7dd5..ab3a4695417 100644 --- a/AK/Vector.h +++ b/AK/Vector.h @@ -53,6 +53,10 @@ private: static constexpr bool CanBePlacedInsideVector = Detail::CanBePlacedInsideVectorHelper::template value; public: + template + requires(!IsRvalueReference) + friend class Vector; + using ValueType = T; Vector() { @@ -314,15 +318,16 @@ public: MUST(try_prepend(values, count)); } - // FIXME: What about assigning from a vector with lower inline capacity? - Vector& operator=(Vector&& other) + template + requires(inline_capacity_u <= inline_capacity) + Vector& operator=(Vector&& other) { - if (this != &other) { + if (reinterpret_cast(this) != reinterpret_cast(&other)) { clear(); m_size = other.m_size; m_capacity = other.m_capacity; m_outline_buffer = other.m_outline_buffer; - if constexpr (inline_capacity > 0) { + if constexpr (inline_capacity_u > 0) { if (!m_outline_buffer) { for (size_t i = 0; i < m_size; ++i) { new (&inline_buffer()[i]) StorageType(move(other.inline_buffer()[i]));