summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2021-10-28 13:07:47 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2021-11-09 13:42:23 +0200
commitc677b3b8afcdc1d7b57353826cc01f378cd25e99 (patch)
treef499b308bc0d42eaaba110bbb13dee6553611434 /src
parent740d652f2dcdc168bc2917279fb86ca83970da3c (diff)
Add compatible weak pointer move operations
We have those on QSharedPointer, so adding them for consistency. Change-Id: Iab5eddc79206605a4bcce46f63e0fb685aed40ff Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src')
-rw-r--r--src/corelib/tools/qsharedpointer_impl.h19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/corelib/tools/qsharedpointer_impl.h b/src/corelib/tools/qsharedpointer_impl.h
index 0e69c18ca4..fa91719709 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 <class X, IfCompatible<X> = true>
+ QWeakPointer(QWeakPointer<X> &&other) noexcept
+ : d(other.d), value(other.value)
+ {
+ other.d = nullptr;
+ other.value = nullptr;
+ }
+
+ template <class X, IfCompatible<X> = true>
+ QWeakPointer &operator=(QWeakPointer<X> &&other) noexcept
+ {
+ QWeakPointer moved(std::move(other));
+ swap(moved);
+ return *this;
+ }
+
QWeakPointer &operator=(const QWeakPointer &other) noexcept
{
QWeakPointer copy(other);