diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index 046d4b7b2a..8da94c8624 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -525,6 +525,31 @@ Q_STATIC_ASSERT((std::is_same::value)); made private. In that case, no error would be reported, but your application would probably crash when you called a member function of \c{w}. + + \sa Q_DISABLE_COPY_MOVE, Q_DISABLE_MOVE +*/ + +/*! + \macro Q_DISABLE_MOVE(Class) + \relates QObject + + Disables the use of move constructors and move assignment operators + for the given \a Class. + + \sa Q_DISABLE_COPY, Q_DISABLE_COPY_MOVE + \since 5.13 +*/ + +/*! + \macro Q_DISABLE_COPY_MOVE(Class) + \relates QObject + + A convenience macro that disables the use of copy constructors, assignment + operators, move constructors and move assignment operators for the given + \a Class, combining Q_DISABLE_COPY and Q_DISABLE_MOVE. + + \sa Q_DISABLE_COPY, Q_DISABLE_MOVE + \since 5.13 */ /*! diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 8680742c94..e3073d80ec 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -372,6 +372,14 @@ typedef double qreal; Class(const Class &) Q_DECL_EQ_DELETE;\ Class &operator=(const Class &) Q_DECL_EQ_DELETE; +#define Q_DISABLE_MOVE(Class) \ + Class(Class &&) = delete; \ + Class &operator=(Class &&) = delete; + +#define Q_DISABLE_COPY_MOVE(Class) \ + Q_DISABLE_COPY(Class) \ + Q_DISABLE_MOVE(Class) + /* No, this is not an evil backdoor. QT_BUILD_INTERNAL just exports more symbols for Qt's internal unit tests. If you want slower loading times and more