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>
This commit is contained in:
parent
740d652f2d
commit
c677b3b8af
@ -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) 2020 Intel Corporation.
|
||||||
** Copyright (C) 2019 Klarälvdalens Datakonsult AB.
|
** Copyright (C) 2019 Klarälvdalens Datakonsult AB.
|
||||||
** Contact: https://www.qt.io/licensing/
|
** Contact: https://www.qt.io/licensing/
|
||||||
@ -583,6 +583,23 @@ public:
|
|||||||
other.value = nullptr;
|
other.value = nullptr;
|
||||||
}
|
}
|
||||||
QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_MOVE_AND_SWAP(QWeakPointer)
|
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 &operator=(const QWeakPointer &other) noexcept
|
||||||
{
|
{
|
||||||
QWeakPointer copy(other);
|
QWeakPointer copy(other);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user