diff options
author | Aurélien Brooke <aurelien@bahiasoft.fr> | 2024-01-12 16:02:16 +0100 |
---|---|---|
committer | Marc Mutz <marc.mutz@qt.io> | 2024-01-15 16:10:22 +0000 |
commit | 89d89f99a794d8edf9282e76a95f78c28ab4d932 (patch) | |
tree | 019dea086a2ae57694b090b680f84b2a52032584 | |
parent | 3be2c90f4a67690828e4bddf054bcd0d7d94bda5 (diff) |
QShader: add move constructor, move-assignment operator and swap
[ChangeLog][QtGui][QShader] Added move constructor, move-assignment
operator and swap member function.
Pick-to: 6.7
Change-Id: I25dbaf4cdd1190204d23121e6ecd8e3947c4b612
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
-rw-r--r-- | src/gui/rhi/qshader.cpp | 30 | ||||
-rw-r--r-- | src/gui/rhi/qshader.h | 4 |
2 files changed, 34 insertions, 0 deletions
diff --git a/src/gui/rhi/qshader.cpp b/src/gui/rhi/qshader.cpp index 14e33d2d43..d5fb53e7e6 100644 --- a/src/gui/rhi/qshader.cpp +++ b/src/gui/rhi/qshader.cpp @@ -299,6 +299,28 @@ QShader &QShader::operator=(const QShader &other) } /*! + \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. */ QShader::~QShader() @@ -308,6 +330,14 @@ QShader::~QShader() } /*! + \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. */ bool QShader::isValid() const diff --git a/src/gui/rhi/qshader.h b/src/gui/rhi/qshader.h index 0b52022596..2465081366 100644 --- a/src/gui/rhi/qshader.h +++ b/src/gui/rhi/qshader.h @@ -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; |