Skip to content

Commit

Permalink
Merge pull request InsightSoftwareConsortium#4691 from N-Dekker/Make-…
Browse files Browse the repository at this point in the history
…ImageRegion-trivially_copyable-LEGACY_REMOVE

PERF: Make `ImageRegion` trivially copyable (LEGACY_REMOVE)
  • Loading branch information
thewtex authored May 22, 2024
2 parents 6517c0f + 9c73fce commit e70671d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
16 changes: 8 additions & 8 deletions Modules/Core/Common/include/itkImageRegion.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@
#include <type_traits> // For conditional and integral_constant.
#include <utility> // For tuple_element and tuple_size.

// Macro added to each `ImageRegion` member function that overrides a virtual member function of `Region`. In the
// future, `ImageRegion` will no longer inherit from `Region`, so then those `ImageRegion` member functions will no
// longer override.
#ifdef ITK_FUTURE_LEGACY_REMOVE
# define itkRegionOverrideMacro // nothing (in the future)
// Macro added to each `ImageRegion` member function that overrides a virtual member function of `Region`, when legacy
// support is enabled. Without legacy support, `ImageRegion` will no longer inherit from `Region`, so then those
// `ImageRegion` member functions will no longer override.
#ifdef ITK_LEGACY_REMOVE
# define itkRegionOverrideMacro // nothing
#else
# define itkRegionOverrideMacro override
#endif
Expand Down Expand Up @@ -78,16 +78,16 @@ class ITK_TEMPLATE_EXPORT ImageBase;
*/
template <unsigned int VImageDimension>
class ITK_TEMPLATE_EXPORT ImageRegion final
#ifndef ITK_FUTURE_LEGACY_REMOVE
// This inheritance is to be removed in the future.
#ifndef ITK_LEGACY_REMOVE
// This inheritance is only there when legacy support is enabled.
: public Region
#endif
{
public:
/** Standard class type aliases. */
using Self = ImageRegion;

#ifndef ITK_FUTURE_LEGACY_REMOVE
#ifndef ITK_LEGACY_REMOVE
using Superclass = Region;
#endif

Expand Down
8 changes: 5 additions & 3 deletions Modules/Core/Common/test/itkImageRegionGTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,13 @@ CheckTrivialCopyabilityOfImageRegion()
{
constexpr bool isImageRegionTriviallyCopyable{ std::is_trivially_copyable_v<itk::ImageRegion<VDimension>> };

#ifdef ITK_FUTURE_LEGACY_REMOVE
static_assert(isImageRegionTriviallyCopyable, "In the future, ImageRegion<VDimension> should be trivially copyable.");
#ifdef ITK_LEGACY_REMOVE
static_assert(isImageRegionTriviallyCopyable,
"When legacy support is removed, ImageRegion<VDimension> should be trivially copyable.");
return isImageRegionTriviallyCopyable;
#else
static_assert(!isImageRegionTriviallyCopyable, "ImageRegion<VDimension> should *not* be trivially copyable.");
static_assert(!isImageRegionTriviallyCopyable,
"When legacy support is enabled, ImageRegion<VDimension> should *not* be trivially copyable.");
return !isImageRegionTriviallyCopyable;
#endif
}
Expand Down

0 comments on commit e70671d

Please sign in to comment.