summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorKieran Bingham <kieran.bingham@ideasonboard.com>2021-02-08 17:07:32 +0000
committerKieran Bingham <kieran.bingham@ideasonboard.com>2021-02-12 14:34:04 +0000
commit41b6d83e6a0c39b31464fce67e69f0d4c5c905cc (patch)
treec087fca1ce930769127b64a3d5e93ad1840d59fa /include
parent1473add188f7a11fb8f5e17d21659a3b30a7063f (diff)
libcamera: class: Provide move and copy disablers
It can be difficult to correctly parse the syntax for copy/move and the associated assignment operators. Provide helpers as syntactic sugar to facilitate disabling either the copy constructor, and copy assignment operator, and the move constructor and move assignment operator in a way which is explicit and clear. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Diffstat (limited to 'include')
-rw-r--r--include/libcamera/class.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/include/libcamera/class.h b/include/libcamera/class.h
index cb278e58..920624d8 100644
--- a/include/libcamera/class.h
+++ b/include/libcamera/class.h
@@ -12,6 +12,24 @@
namespace libcamera {
#ifndef __DOXYGEN__
+#define LIBCAMERA_DISABLE_COPY(klass) \
+ klass(const klass &) = delete; \
+ klass &operator=(const klass &) = delete;
+
+#define LIBCAMERA_DISABLE_MOVE(klass) \
+ klass(klass &&) = delete; \
+ klass &operator=(klass &&) = delete;
+
+#define LIBCAMERA_DISABLE_COPY_AND_MOVE(klass) \
+ LIBCAMERA_DISABLE_COPY(klass) \
+ LIBCAMERA_DISABLE_MOVE(klass)
+#else
+#define LIBCAMERA_DISABLE_COPY(klass)
+#define LIBCAMERA_DISABLE_MOVE(klass)
+#define LIBCAMERA_DISABLE_COPY_AND_MOVE(klass)
+#endif
+
+#ifndef __DOXYGEN__
#define LIBCAMERA_DECLARE_PRIVATE(klass) \
public: \
class Private; \