qxLib
copyable_movable.h
Go to the documentation of this file.
1 /**
2 
3  @file copyable_movable.h
4  @author Khrapov
5  @date 7.08.2022
6  @copyright © Nick Khrapov, 2022. All right reserved.
7 
8 **/
9 #pragma once
10 
11 /**
12  @def QX_COPYABLE
13  @brief Define class as default copyable
14  @param className - class name
15 **/
16 #define QX_COPYABLE(className) \
17  className(const className&) = default; \
18  className& operator=(const className&) = default
19 
20 /**
21  @def QX_MOVABLE
22  @brief Define class as default movable
23  @param className - class name
24 **/
25 #define QX_MOVABLE(className) \
26  className(className&&) noexcept = default; \
27  className& operator=(className&&) noexcept = default
28 
29 /**
30  @def QX_COPYMOVABLE
31  @brief Define class as default copyable and movable
32  @param className - class name
33 **/
34 #define QX_COPYMOVABLE(className) \
35  QX_COPYABLE(className); \
36  QX_MOVABLE(className)
37 
38 /**
39  @def QX_NONCOPYABLE
40  @brief Define class as non copyable
41  @param className - class name
42 **/
43 #define QX_NONCOPYABLE(className) \
44  className(const className&) = delete; \
45  className& operator=(const className&) = delete
46 
47 /**
48  @def QX_NONMOVABLE
49  @brief Define class as non movable
50  @param className - class name
51 **/
52 #define QX_NONMOVABLE(className) \
53  className(className&&) noexcept = delete; \
54  className& operator=(className&&) noexcept = delete
55 
56 /**
57  @def QX_NONCOPYMOVABLE
58  @brief Define class as non copyable and non movable
59  @param className - class name
60 **/
61 #define QX_NONCOPYMOVABLE(className) \
62  QX_NONCOPYABLE(className); \
63  QX_NONMOVABLE(className)