Utility macros for declaring copy and move constructors and assignment operations. More...
Go to the source code of this file.
Macros | |
#define | OGDF_COPY_CONSTR(cls) cls(const cls& copy) |
Declares the copy constructor for class cls . More... | |
#define | OGDF_COPY_MOVE_BY_SWAP(cls) |
Provide move construct/assign and copy assign given there is a copy constructor and swap. More... | |
#define | OGDF_COPY_OP(cls) cls& operator=(const cls& copy) |
Declares the copy assignment operation for class cls . Don't forget to return *this ;. More... | |
#define | OGDF_DEFAULT_COPY(cls) |
Explicitly provides default copy construction and assignment for class cls . More... | |
#define | OGDF_DEFAULT_MOVE(cls) |
Explicitly provides default move construction and assignment for class cls . More... | |
#define | OGDF_MOVE_CONSTR(cls) cls(cls&& move) noexcept : cls() |
Declares the move constructor for class cls . More... | |
#define | OGDF_MOVE_OP(cls) cls& operator=(cls&& move) noexcept |
Declares the move assignment operation for class cls . More... | |
#define | OGDF_NO_COPY(cls) |
Explicitly disables (deletes) copy construction and assignment for class cls . More... | |
#define | OGDF_NO_MOVE(cls) |
Explicitly disables (deletes) move construction and assignment for class cls . More... | |
#define | OGDF_SWAP_OP(cls) friend void swap(cls& first, cls& second) noexcept |
Declares the swap function for class cls . More... | |
Utility macros for declaring copy and move constructors and assignment operations.
Definition in file copy_move.h.
#define OGDF_COPY_CONSTR | ( | cls | ) | cls(const cls& copy) |
Declares the copy constructor for class cls
.
Definition at line 57 of file copy_move.h.
#define OGDF_COPY_MOVE_BY_SWAP | ( | cls | ) |
Provide move construct/assign and copy assign given there is a copy constructor and swap.
Requires custom implementations of OGDF_COPY_CONSTR and OGDF_SWAP_OP (may not be the std::swap via move to temporary) and automatically provides OGDF_COPY_OP, OGDF_MOVE_CONSTR, and OGDF_MOVE_OP.
See https://stackoverflow.com/a/3279550 for more details on this idiom. Note that your swap implementation is expected to be noexcept (as declared e.g. by OGDF_SWAP_OP) as all methods declared by this macro are also noexcept (see https://stackoverflow.com/a/7628345).
Definition at line 76 of file copy_move.h.
#define OGDF_COPY_OP | ( | cls | ) | cls& operator=(const cls& copy) |
Declares the copy assignment operation for class cls
. Don't forget to return *this
;.
Definition at line 59 of file copy_move.h.
#define OGDF_DEFAULT_COPY | ( | cls | ) |
Explicitly provides default copy construction and assignment for class cls
.
Definition at line 47 of file copy_move.h.
#define OGDF_DEFAULT_MOVE | ( | cls | ) |
Explicitly provides default move construction and assignment for class cls
.
Definition at line 52 of file copy_move.h.
#define OGDF_MOVE_CONSTR | ( | cls | ) | cls(cls&& move) noexcept : cls() |
Declares the move constructor for class cls
.
Definition at line 61 of file copy_move.h.
#define OGDF_MOVE_OP | ( | cls | ) | cls& operator=(cls&& move) noexcept |
Declares the move assignment operation for class cls
.
Definition at line 63 of file copy_move.h.
#define OGDF_NO_COPY | ( | cls | ) |
Explicitly disables (deletes) copy construction and assignment for class cls
.
Definition at line 37 of file copy_move.h.
#define OGDF_NO_MOVE | ( | cls | ) |
Explicitly disables (deletes) move construction and assignment for class cls
.
Definition at line 42 of file copy_move.h.
#define OGDF_SWAP_OP | ( | cls | ) | friend void swap(cls& first, cls& second) noexcept |
Declares the swap function for class cls
.
Definition at line 65 of file copy_move.h.