From a0dfa8c4d29a005009d04dcb52452efb9d74e26e Mon Sep 17 00:00:00 2001 From: Fabian Kosmale Date: Mon, 26 Sep 2022 17:38:14 +0200 Subject: Replace qExchange calls with std::exchange qExchange is one of the few remaining functionalities that have not been moved out of qglobal. Given that std::exchange exists in the standard, we can simply move to it everywhere... ...if it weren't for the fact that std::exchange is only constexpr in C++20, and only has its noexceptness specified in (most likely) C++23. Still, we want to move to the existing std functionality where possible, to allow the removal of qglobal includes in lieu of something more fine-grained in the future. So leave any constexpr calls[1] alone for now (and observe that none of our current usages cares about the conditional noexceptness), but replace everything else. [1] QScopedValueRollback' ctor and QExplicitlySharedDataPointerV2::take Task-number: QTBUG-99313 Change-Id: I599cb9846cf319c7ffd3457130938347a75aad25 Reviewed-by: Thiago Macieira --- src/corelib/tools/qscopedpointer.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/corelib/tools/qscopedpointer.h') diff --git a/src/corelib/tools/qscopedpointer.h b/src/corelib/tools/qscopedpointer.h index 1ad7acb0f4..1637bb40a5 100644 --- a/src/corelib/tools/qscopedpointer.h +++ b/src/corelib/tools/qscopedpointer.h @@ -120,7 +120,7 @@ public: { if (d == other) return; - T *oldD = qExchange(d, other); + T *oldD = std::exchange(d, other); Cleanup::cleanup(oldD); } @@ -128,7 +128,7 @@ public: QT_DEPRECATED_VERSION_X_6_1("Use std::unique_ptr instead, and call release().") T *take() noexcept { - T *oldD = qExchange(d, nullptr); + T *oldD = std::exchange(d, nullptr); return oldD; } #endif -- cgit v1.2.3