Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PERF: Make ImageRegion trivially copyable (LEGACY_REMOVE) #4691

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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