Skip to content

Commit

Permalink
ENH: Add ITK_DEFAULT_COPY_AND_MOVE(TypeName) macro definition
Browse files Browse the repository at this point in the history
Explicitly "defaults" the copy constructor, copy assignment operator, move
constructor, and move assignment operator of the specified class.

Addresses issue #4645
"Defaulting copy constructor, copy assignment, move constructor, and move
assignment functions", reported by Jon Haitz Legarreta Gorroño.
  • Loading branch information
N-Dekker authored and hjmjohnson committed May 15, 2024
1 parent ea4ce21 commit f65623b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/itk_dict.txt
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ Vkept
Vox
Wachowiak
Wanlin
Wdeprecated
Wi
Wtautological
Xu
Expand Down
14 changes: 14 additions & 0 deletions Modules/Core/Common/include/itkMacro.h
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,20 @@ namespace itk
#endif


/** Explicitly "defaults" the copy constructor, copy assignment operator, move constructor, and move assignment operator
of the specified class. Especially meant to address compiler warnings like:
- "warning: definition of implicit copy assignment operator for '<TypeName>' is deprecated because it has a
user-declared destructor [-Wdeprecated]" (Mac10.13-AppleClang)
- "warning C5267: definition of implicit copy constructor for '<TypeName>' is deprecated because it has a user-provided
destructor." (Visual Studio 2022/MSVC)
Intended to be used in the public section of a class. */
#define ITK_DEFAULT_COPY_AND_MOVE(TypeName) \
TypeName(const TypeName &) = default; \
TypeName & operator=(const TypeName &) = default; \
TypeName(TypeName &&) = default; \
TypeName & operator=(TypeName &&) = default


// When ITK_EXPERIMENTAL_CXX20_REWRITTEN_UNEQUAL_OPERATOR is defined, ITK uses
// the ability for operator!= to be rewritten automatically in terms of
// operator==, as introduced with C++20. This macro is experimental. It may be
Expand Down

0 comments on commit f65623b

Please sign in to comment.