Skip to content

Commit aeca49f

Browse files
committed
Use constexpr in ImportImageFilter
1 parent a635265 commit aeca49f

2 files changed

Lines changed: 6 additions & 17 deletions

File tree

Code/IO/include/sitkImportImageFilter.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,7 @@ class SITKIO_EXPORT ImportImageFilter : public ImageReaderBase
118118
// components per pixel needs to be set, otherwise the method
119119
// does not exist. This is done with the enable if idiom.
120120
template <class TImageType>
121-
typename std::enable_if<!IsVector<TImageType>::Value>::type
122-
SetNumberOfComponentsOnImage(TImageType *)
123-
{}
124-
template <class TImageType>
125-
typename std::enable_if<IsVector<TImageType>::Value>::type
121+
void
126122
SetNumberOfComponentsOnImage(TImageType *);
127123

128124
private:

Code/IO/src/sitkImportImageFilter.cxx

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -536,22 +536,15 @@ ImportImageFilter::ExecuteInternal()
536536
TheContainerWillTakeCareOfDeletingTheMemoryBuffer);
537537

538538

539-
//
540-
// Meta-programmed method to set the number of components if a
541-
// vector image
542-
//
543-
this->SetNumberOfComponentsOnImage(image.GetPointer());
539+
// set the number of components if a vector image
540+
if constexpr (IsVector<ImageType>::Value)
541+
{
542+
image->SetNumberOfComponentsPerPixel(m_NumberOfComponentsPerPixel);
543+
}
544544

545545
// This line must be the last line in the function to prevent a deep
546546
// copy caused by a implicit sitk::MakeUnique
547547
return Image(image);
548548
}
549549

550-
template <class TFilterType>
551-
typename std::enable_if<IsVector<TFilterType>::Value>::type
552-
ImportImageFilter::SetNumberOfComponentsOnImage(TFilterType * image)
553-
{
554-
image->SetNumberOfComponentsPerPixel(m_NumberOfComponentsPerPixel);
555-
}
556-
557550
} // namespace itk::simple

0 commit comments

Comments
 (0)