summaryrefslogtreecommitdiffstats
path: root/src/corelib/global/qcompare.cpp
diff options
context:
space:
mode:
authorIvan Solovev <ivan.solovev@qt.io>2024-05-23 16:56:59 +0200
committerIvan Solovev <ivan.solovev@qt.io>2024-06-07 08:14:59 +0200
commitb1ae4334ea11f6942c7ce37a80a3aa98a3447809 (patch)
treead80f74b708a258580cf0360ea4a030e5d87a175 /src/corelib/global/qcompare.cpp
parentd6e1df3513c7d5b6e93d68583fc4c1febb7bcd85 (diff)
Deprecate Qt::compareThreeWay() overload for pointers
compareThreeWay() was supposed to be an operator<=>(), but for C++17. The idea was that at some point when we unconditionally demand C++20, people could just replace all the usages of compareThreeWay() with operator<=>(). However, the Qt::compareThreeWay() overload for pointers is different from the operator<=>() for pointers, because it is actually using std::less{} or std::compare_three_way{} to do the comparison, thus avoiding an UB. This is not bad as such, but can potentially lead to UB when mass-replacing all compareThreeWay() calls with operator<=>(). To avoid this problem, deprecate the overload, and suggest to use the Qt::totally_ordered_wrapper together with the respective overload instead. Found in API Review. [ChangeLog][QtCore][QtCompare] Deprecate Qt::compareThreeWay() overload for pointers. Pick-to: 6.8 Change-Id: I9c57871145dc3cb9656d6006db88b48a1553bef4 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Diffstat (limited to 'src/corelib/global/qcompare.cpp')
-rw-r--r--src/corelib/global/qcompare.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/corelib/global/qcompare.cpp b/src/corelib/global/qcompare.cpp
index d32f4ca251f..5a2ad0e2ee4 100644
--- a/src/corelib/global/qcompare.cpp
+++ b/src/corelib/global/qcompare.cpp
@@ -1274,9 +1274,12 @@ CHECK(strong, equivalent);
\l Qt::partial_ordering::unordered is returned.
*/
+#if QT_DEPRECATED_SINCE(6, 8)
/*!
\fn template <typename LeftType, typename RightType, Qt::if_compatible_pointers<LeftType, RightType> = true> Qt::compareThreeWay(const LeftType *lhs, const RightType *rhs)
\since 6.7
+ \deprecated [6.8] Wrap the pointers into Qt::totally_ordered_wrapper and
+ use the respective Qt::compareThreeWay() overload instead.
\relates <QtCompare>
\overload
@@ -1289,6 +1292,7 @@ CHECK(strong, equivalent);
Returns an instance of \l Qt::strong_ordering that represents the relation
between \a lhs and \a rhs.
*/
+#endif // QT_DEPRECATED_SINCE(6, 8)
/*!
\fn template <class Enum, Qt::if_enum<Enum> = true> Qt::compareThreeWay(Enum lhs, Enum rhs)