Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

copy_move.h File Reference

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...
 

Detailed Description

Utility macros for declaring copy and move constructors and assignment operations.

Author
Simon D. Fink
License:
This file is part of the Open Graph Drawing Framework (OGDF).
Copyright (C)
See README.md in the OGDF root directory for details.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License Version 2 or 3 as published by the Free Software Foundation; see the file LICENSE.txt included in the packaging of this file for details.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, see http://www.gnu.org/copyleft/gpl.html

Definition in file copy_move.h.

Macro Definition Documentation

◆ OGDF_COPY_CONSTR

#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.

◆ OGDF_COPY_MOVE_BY_SWAP

#define OGDF_COPY_MOVE_BY_SWAP (   cls)
Value:
\
cls& operator=(cls copy_by_value) noexcept { \
swap(*this, copy_by_value); \
return *this; \
} \
OGDF_MOVE_CONSTR(cls) { swap(*this, move); }

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.

◆ OGDF_COPY_OP

#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.

◆ OGDF_DEFAULT_COPY

#define OGDF_DEFAULT_COPY (   cls)
Value:
cls(const cls& copy) = default; \
cls& operator=(const cls& copy) = default;

Explicitly provides default copy construction and assignment for class cls.

Definition at line 47 of file copy_move.h.

◆ OGDF_DEFAULT_MOVE

#define OGDF_DEFAULT_MOVE (   cls)
Value:
cls(cls&& move) noexcept = default; \
cls& operator=(cls&& move) noexcept = default;

Explicitly provides default move construction and assignment for class cls.

Definition at line 52 of file copy_move.h.

◆ OGDF_MOVE_CONSTR

#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.

◆ OGDF_MOVE_OP

#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.

◆ OGDF_NO_COPY

#define OGDF_NO_COPY (   cls)
Value:
cls(const cls& copy) = delete; \
cls& operator=(const cls& copy) = delete;

Explicitly disables (deletes) copy construction and assignment for class cls.

Definition at line 37 of file copy_move.h.

◆ OGDF_NO_MOVE

#define OGDF_NO_MOVE (   cls)
Value:
cls(cls&& move) = delete; \
cls& operator=(cls&& move) = delete;

Explicitly disables (deletes) move construction and assignment for class cls.

Definition at line 42 of file copy_move.h.

◆ OGDF_SWAP_OP

#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.

Minisat::Internal::copy
static void copy(const T &from, T &to)
Definition: Alg.h:61
backward::details::move
const T & move(const T &v)
Definition: backward.hpp:243