Concept Checking Is Same Type#

Synopsis#

Check at compilation time that 2 given types are the same.

Results#

Code#

C++#

#include "itkImage.h"
#include "itkConceptChecking.h"

template <typename TImage, class TValue>
void
CheckIfPixelTypeIsTheSameAs(const TImage * const)
{
  itkConceptMacro(nameOfCheck, (itk::Concept::SameType<typename TImage::PixelType, TValue>));
}
int
main()
{
  constexpr unsigned int Dimension = 2;
  using PixelType = unsigned char;
  using ImageType = itk::Image<PixelType, Dimension>;
  auto image = ImageType::New();

  CheckIfPixelTypeIsTheSameAs<ImageType, unsigned char>(image.GetPointer());

  using ImageType2 = itk::Image<PixelType, Dimension>;

  CheckIfPixelTypeIsTheSameAs<ImageType, ImageType2::PixelType>(image.GetPointer());

  return EXIT_SUCCESS;
}