From 8de6762112640bf5ddb975115f9a60db91ce73af Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 26 Nov 2021 13:06:58 +0100 Subject: [PATCH] QVLA: separate control from inline storage [2/N]: Move Up Methods [3/3] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Move the remaining methods to the QVLABase base class that can be moved, being those which do not depend on QVLAStorage::array. Include the relational operators this time around. Task-number: QTBUG-84785 Change-Id: I0f22b076791496833cba033c1be2a69ec8b129a1 Reviewed-by: Fabian Kosmale Reviewed-by: MÃ¥rten Nordheim --- src/corelib/tools/qvarlengtharray.h | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/src/corelib/tools/qvarlengtharray.h b/src/corelib/tools/qvarlengtharray.h index de26b06a5d..fa5643ee7a 100644 --- a/src/corelib/tools/qvarlengtharray.h +++ b/src/corelib/tools/qvarlengtharray.h @@ -187,6 +187,17 @@ public: iterator erase(const_iterator pos) { return erase(pos, pos + 1); } protected: + template + bool equal(const QVLABase &other) const + { + return std::equal(begin(), end(), other.begin(), other.end()); + } + template + bool less_than(const QVLABase &other) const + { + return std::lexicographical_compare(begin(), end(), other.begin(), other.end()); + } + bool isValidIterator(const const_iterator &i) const { const std::less less = {}; @@ -200,6 +211,8 @@ class QVarLengthArray : public QVLABase, // ### Qt 7: swap base class order public QVLAStorage { + template + friend class QVarLengthArray; using Base = QVLABase; using Storage = QVLAStorage; static_assert(std::is_nothrow_destructible_v, "Types with throwing destructors are not supported in Qt containers."); @@ -512,7 +525,7 @@ public: template friend QTypeTraits::compare_eq_result operator==(const QVarLengthArray &l, const QVarLengthArray &r) { - return std::equal(l.begin(), l.end(), r.begin(), r.end()); + return l.equal(r); } template friend @@ -526,8 +539,7 @@ public: noexcept(noexcept(std::lexicographical_compare(lhs.begin(), lhs.end(), rhs.begin(), rhs.end()))) { - return std::lexicographical_compare(lhs.begin(), lhs.end(), - rhs.begin(), rhs.end()); + return lhs.less_than(rhs); } template friend @@ -553,6 +565,13 @@ public: #endif private: + template + bool equal(const QVarLengthArray &other) const + { return Base::equal(other); } + template + bool less_than(const QVarLengthArray &other) const + { return Base::less_than(other); } + void reallocate(qsizetype size, qsizetype alloc); using Base::isValidIterator;