From e6d4967f0bf150d746aceca3d9b209bde9728e8a Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 19 Jan 2022 08:40:34 +0100 Subject: [PATCH] QArrayDataPointer: don't overload qSwap(), provide ADL-swap() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit qSwap() is our wrapper around using std::swap; swap(lhs, rhs); it needn't and shouldn't be overloaded. ADL swap() should be, though, so qSwap(), std::ranges::swap() and all the other adl_swap()s out there all find the optimized version. Qt 5.15 has it correct, Qt 6 wrong. Fix it. Can't pick to 6.2 because, while backwards-source-compatible, because the generic qSwap() template provides the name for both qualified and unqualified calls, it's not forwards-source-compatible: A new user of ADL swap // compile error w/o `using std::swap`, pessimization otherwise: swap(dp1, dp2); would break or performance-regress when going back to an older version. Pick-to: 6.3 Change-Id: I725949a4aa9ae438a182b4b7552ff2dced767e2f Reviewed-by: Andrei Golubev Reviewed-by: MÃ¥rten Nordheim Reviewed-by: Fabian Kosmale --- src/corelib/tools/qarraydatapointer.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/tools/qarraydatapointer.h b/src/corelib/tools/qarraydatapointer.h index 27598109198..f7280b847f9 100644 --- a/src/corelib/tools/qarraydatapointer.h +++ b/src/corelib/tools/qarraydatapointer.h @@ -415,7 +415,7 @@ public: }; template -inline void qSwap(QArrayDataPointer &p1, QArrayDataPointer &p2) noexcept +inline void swap(QArrayDataPointer &p1, QArrayDataPointer &p2) noexcept { p1.swap(p2); }