QShader: add move constructor, move-assignment operator and swap

[ChangeLog][QtGui][QShader] Added move constructor, move-assignment
operator and swap member function.

Change-Id: I25dbaf4cdd1190204d23121e6ecd8e3947c4b612
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
(cherry picked from commit 89d89f99a794d8edf9282e76a95f78c28ab4d932)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Aurélien Brooke 2024-01-12 16:02:16 +01:00 committed by Qt Cherry-pick Bot
parent 417cf07c5d
commit 2634ad2e6c
2 changed files with 34 additions and 0 deletions

View File

@ -298,6 +298,28 @@ QShader &QShader::operator=(const QShader &other)
return *this;
}
/*!
\fn QShader::QShader(QShader &&other) noexcept
\since 6.7
Move-constructs a new QShader from \a other.
\note The moved-from object \a other is placed in a
partially-formed state, in which the only valid operations are
destruction and assignment of a new value.
*/
/*!
\fn QShader &QShader::operator=(QShader &&other)
\since 6.7
Move-assigns \a other to this QShader instance.
\note The moved-from object \a other is placed in a
partially-formed state, in which the only valid operations are
destruction and assignment of a new value.
*/
/*!
Destructor.
*/
@ -307,6 +329,14 @@ QShader::~QShader()
delete d;
}
/*!
\fn void QShader::swap(QShader &other)
\since 6.7
Swaps shader \a other with this shader. This operation is very fast and
never fails.
*/
/*!
\return true if the QShader contains at least one shader version.
*/

View File

@ -117,7 +117,11 @@ public:
QShader();
QShader(const QShader &other);
QShader &operator=(const QShader &other);
QShader(QShader &&other) noexcept : d(std::exchange(other.d, nullptr)) {}
QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QShader)
~QShader();
void swap(QShader &other) noexcept { qt_ptr_swap(d, other.d); }
void detach();
bool isValid() const;