Long live Q_DISABLE_COPY(_MOVE)_X
Just like the _X-less versions, but with the possibility of supplying a message, for instance: class Obj : public QObject { Q_DISABLE_COPY_MOVE_X("This class has identity semantics"); }; class Manager { Q_DISABLE_COPY_X("This class manages a resource, so copy is not supported, use a move instead"); }; [ChangeLog][QtCore][QtGlobal] Added the Q_DISABLE_COPY_X and Q_DISABLE_COPY_MOVE_X macros. Change-Id: I9eda2356ea37ead6764eafcb6a13800dbfdf7721 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
0ed5d4d674
commit
bac583d090
@ -29,6 +29,15 @@ QT_BEGIN_NAMESPACE
|
||||
Class(Class &&) = delete; \
|
||||
Class &operator=(Class &&) = delete;
|
||||
|
||||
#define Q_DISABLE_COPY_X(Class, reason) \
|
||||
Class(const Class &) Q_DECL_EQ_DELETE_X(reason);\
|
||||
Class &operator=(const Class &) Q_DECL_EQ_DELETE_X(reason);
|
||||
|
||||
#define Q_DISABLE_COPY_MOVE_X(Class, reason) \
|
||||
Q_DISABLE_COPY_X(Class, reason) \
|
||||
Class(Class &&) Q_DECL_EQ_DELETE_X(reason); \
|
||||
Class &operator=(Class &&) Q_DECL_EQ_DELETE_X(reason);
|
||||
|
||||
/*
|
||||
Implementing a move assignment operator using an established
|
||||
technique (move-and-swap, pure swap) is just boilerplate.
|
||||
|
@ -43,7 +43,7 @@
|
||||
application would probably crash when you called a member function
|
||||
of \c{w}.
|
||||
|
||||
\sa Q_DISABLE_COPY_MOVE
|
||||
\sa Q_DISABLE_COPY_MOVE, Q_DISABLE_COPY_X
|
||||
*/
|
||||
|
||||
/*!
|
||||
@ -54,6 +54,38 @@
|
||||
operators, move constructors and move assignment operators for the given
|
||||
\a Class.
|
||||
|
||||
\sa Q_DISABLE_COPY
|
||||
\sa Q_DISABLE_COPY, Q_DISABLE_COPY_MOVE_X
|
||||
\since 5.13
|
||||
*/
|
||||
|
||||
/*!
|
||||
\macro Q_DISABLE_COPY_X(Class, reason)
|
||||
\relates <QtClassHelperMacros>
|
||||
\since 6.9
|
||||
|
||||
Like Q_DISABLE_COPY, this macro disables copy operations for the
|
||||
class \a Class.
|
||||
|
||||
In addition, this documents the \a reason why this class does not support
|
||||
copy operations. In C++26 this will cause the compiler to report that
|
||||
reason in its error message against any code that attempts these
|
||||
unsupported operations.
|
||||
|
||||
\sa Q_DISABLE_COPY, Q_DISABLE_COPY_MOVE_X, Q_DECL_EQ_DELETE_X
|
||||
*/
|
||||
|
||||
/*!
|
||||
\macro Q_DISABLE_COPY_MOVE_X(Class, reason)
|
||||
\relates <QtClassHelperMacros>
|
||||
\since 6.9
|
||||
|
||||
Like Q_DISABLE_COPY_MOVE, this macro disables copy and move operations for the
|
||||
class \a Class.
|
||||
|
||||
In addition, this documents the \a reason why this class does not support
|
||||
copy/move operations. In C++26 this will cause the compiler to report that
|
||||
reason in its error message against any code that attempts these
|
||||
unsupported operations.
|
||||
|
||||
\sa Q_DISABLE_COPY_X, Q_DECL_EQ_DELETE_X
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user