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;