From c677b3b8afcdc1d7b57353826cc01f378cd25e99 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Thu, 28 Oct 2021 13:07:47 +0200 Subject: [PATCH] Add compatible weak pointer move operations We have those on QSharedPointer, so adding them for consistency. Change-Id: Iab5eddc79206605a4bcce46f63e0fb685aed40ff Reviewed-by: Thiago Macieira --- src/corelib/tools/qsharedpointer_impl.h | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/corelib/tools/qsharedpointer_impl.h b/src/corelib/tools/qsharedpointer_impl.h index 0e69c18ca42..fa917197096 100644 --- a/src/corelib/tools/qsharedpointer_impl.h +++ b/src/corelib/tools/qsharedpointer_impl.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2020 The Qt Company Ltd. +** Copyright (C) 2021 The Qt Company Ltd. ** Copyright (C) 2020 Intel Corporation. ** Copyright (C) 2019 Klarälvdalens Datakonsult AB. ** Contact: https://www.qt.io/licensing/ @@ -583,6 +583,23 @@ public: other.value = nullptr; } QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_MOVE_AND_SWAP(QWeakPointer) + + template = true> + QWeakPointer(QWeakPointer &&other) noexcept + : d(other.d), value(other.value) + { + other.d = nullptr; + other.value = nullptr; + } + + template = true> + QWeakPointer &operator=(QWeakPointer &&other) noexcept + { + QWeakPointer moved(std::move(other)); + swap(moved); + return *this; + } + QWeakPointer &operator=(const QWeakPointer &other) noexcept { QWeakPointer copy(other);