Skip to content

Commit f65623b

Browse files
N-Dekkerhjmjohnson
authored andcommitted
ENH: Add ITK_DEFAULT_COPY_AND_MOVE(TypeName) macro definition
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.
1 parent ea4ce21 commit f65623b

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

.github/workflows/itk_dict.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ Vkept
224224
Vox
225225
Wachowiak
226226
Wanlin
227+
Wdeprecated
227228
Wi
228229
Wtautological
229230
Xu

Modules/Core/Common/include/itkMacro.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,20 @@ namespace itk
405405
#endif
406406

407407

408+
/** Explicitly "defaults" the copy constructor, copy assignment operator, move constructor, and move assignment operator
409+
of the specified class. Especially meant to address compiler warnings like:
410+
- "warning: definition of implicit copy assignment operator for '<TypeName>' is deprecated because it has a
411+
user-declared destructor [-Wdeprecated]" (Mac10.13-AppleClang)
412+
- "warning C5267: definition of implicit copy constructor for '<TypeName>' is deprecated because it has a user-provided
413+
destructor." (Visual Studio 2022/MSVC)
414+
Intended to be used in the public section of a class. */
415+
#define ITK_DEFAULT_COPY_AND_MOVE(TypeName) \
416+
TypeName(const TypeName &) = default; \
417+
TypeName & operator=(const TypeName &) = default; \
418+
TypeName(TypeName &&) = default; \
419+
TypeName & operator=(TypeName &&) = default
420+
421+
408422
// When ITK_EXPERIMENTAL_CXX20_REWRITTEN_UNEQUAL_OPERATOR is defined, ITK uses
409423
// the ability for operator!= to be rewritten automatically in terms of
410424
// operator==, as introduced with C++20. This macro is experimental. It may be

0 commit comments

Comments
 (0)