summaryrefslogtreecommitdiffstats
path: root/src/corelib/text/qanystringview.h
diff options
context:
space:
mode:
authorIvan Solovev <ivan.solovev@qt.io>2024-02-29 16:18:23 +0100
committerIvan Solovev <ivan.solovev@qt.io>2024-03-02 00:12:55 +0100
commit2bc9ad0e5dd75cf69f4a8bf94a6a917de2b4e8c4 (patch)
tree118c169f5e025f59525002b79c82d63852f7c957 /src/corelib/text/qanystringview.h
parent868a5342bb3af21bd9d078c420a43f4a57cb61a1 (diff)
QAnyStringView: use new comparison helper macros
Also extend unit-test to use new test helper functions. Remove the now-redundant test for three-way comparison, because it is covered by the test helper functions. Task-number: QTBUG-117661 Change-Id: I242b560c281245e04e34353c80000a20998fc677 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'src/corelib/text/qanystringview.h')
-rw-r--r--src/corelib/text/qanystringview.h26
1 files changed, 9 insertions, 17 deletions
diff --git a/src/corelib/text/qanystringview.h b/src/corelib/text/qanystringview.h
index d74d371e2d..b7f3650275 100644
--- a/src/corelib/text/qanystringview.h
+++ b/src/corelib/text/qanystringview.h
@@ -4,6 +4,7 @@
#ifndef QANYSTRINGVIEW_H
#define QANYSTRINGVIEW_H
+#include <QtCore/qcompare.h>
#include <QtCore/qlatin1stringview.h>
#include <QtCore/qstringview.h>
#include <QtCore/qutf8stringview.h>
@@ -301,24 +302,15 @@ public:
{ return size(); }
private:
- [[nodiscard]] friend inline bool operator==(QAnyStringView lhs, QAnyStringView rhs) noexcept
+ friend bool comparesEqual(const QAnyStringView &lhs, const QAnyStringView &rhs) noexcept
{ return QAnyStringView::equal(lhs, rhs); }
- [[nodiscard]] friend inline bool operator!=(QAnyStringView lhs, QAnyStringView rhs) noexcept
- { return !QAnyStringView::equal(lhs, rhs); }
-
-#if defined(__cpp_impl_three_way_comparison) && !defined(Q_QDOC)
- [[nodiscard]] friend inline auto operator<=>(QAnyStringView lhs, QAnyStringView rhs) noexcept
- { return QAnyStringView::compare(lhs, rhs) <=> 0; }
-#else
- [[nodiscard]] friend inline bool operator<=(QAnyStringView lhs, QAnyStringView rhs) noexcept
- { return QAnyStringView::compare(lhs, rhs) <= 0; }
- [[nodiscard]] friend inline bool operator>=(QAnyStringView lhs, QAnyStringView rhs) noexcept
- { return QAnyStringView::compare(lhs, rhs) >= 0; }
- [[nodiscard]] friend inline bool operator<(QAnyStringView lhs, QAnyStringView rhs) noexcept
- { return QAnyStringView::compare(lhs, rhs) < 0; }
- [[nodiscard]] friend inline bool operator>(QAnyStringView lhs, QAnyStringView rhs) noexcept
- { return QAnyStringView::compare(lhs, rhs) > 0; }
-#endif
+ friend Qt::strong_ordering
+ compareThreeWay(const QAnyStringView &lhs, const QAnyStringView &rhs) noexcept
+ {
+ const int res = QAnyStringView::compare(lhs, rhs);
+ return Qt::compareThreeWay(res, 0);
+ }
+ Q_DECLARE_STRONGLY_ORDERED(QAnyStringView)
#ifndef QT_NO_DEBUG_STREAM
Q_CORE_EXPORT friend QDebug operator<<(QDebug d, QAnyStringView s);