diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h index 443789b411d..35dc2861917 100644 --- a/src/corelib/tools/qlist.h +++ b/src/corelib/tools/qlist.h @@ -162,22 +162,10 @@ public: void swap(QList &other) noexcept { qSwap(d, other.d); } - template - friend QTypeTraits::compare_eq_result operator==(const QList &l, const QList &r) - { - if (l.size() != r.size()) - return false; - if (l.begin() == r.begin()) - return true; - - // do element-by-element comparison - return l.d->compare(l.begin(), r.begin(), l.size()); - } - template - friend QTypeTraits::compare_eq_result operator!=(const QList &l, const QList &r) - { - return !(l == r); - } + template + friend QTypeTraits::compare_eq_result operator==(const QList &l, const QList &r); + template + friend QTypeTraits::compare_eq_result operator!=(const QList &l, const QList &r); qsizetype size() const noexcept { return d->size; } qsizetype count() const noexcept { return size(); } @@ -792,6 +780,24 @@ size_t qHash(const QList &key, size_t seed = 0) return qHashRange(key.cbegin(), key.cend(), seed); } +template +QTypeTraits::compare_eq_result operator==(const QList &l, const QList &r) +{ + if (l.size() != r.size()) + return false; + if (l.begin() == r.begin()) + return true; + + // do element-by-element comparison + return l.d->compare(l.begin(), r.begin(), l.size()); +} + +template +QTypeTraits::compare_eq_result operator!=(const QList &l, const QList &r) +{ + return !(l == r); +} + template auto operator<(const QList &lhs, const QList &rhs) noexcept(noexcept(std::lexicographical_compare(lhs.begin(), lhs.end(),