|
|
Line 1: |
Line 1: |
| ==ConceptChecking.cxx== | | {{warning|1=The media wiki content on this page is no longer maintained. The examples presented on the https://itk.org/Wiki/* pages likely require ITK version 4.13 or earlier releases. In many cases, the examples on this page no longer conform to the best practices for modern ITK versions. |
| <source lang="cpp">
| | }} |
| #include <itkConceptChecking.h>
| |
| #include <itkImage.h>
| |
|
| |
|
| template <typename TImage>
| | [https://itk.org/ITKExamples[ITK Sphinx Examples]] |
| void MyFunction(const TImage* const image)
| |
| {
| |
| itkConceptMacro( nameOfCheck, ( itk::Concept::IsFloatingPoint<typename TImage::ValueType> ) );
| |
| }
| |
| | |
| int main(int, char*[])
| |
| {
| |
| typedef itk::Image<float, 2> FloatImageType;
| |
| FloatImageType::Pointer floatImage = FloatImageType::New();
| |
| MyFunction(floatImage.GetPointer());
| |
| | |
| typedef itk::Image<double, 2> DoubleImageType;
| |
| DoubleImageType::Pointer doubleImage = DoubleImageType::New();
| |
| MyFunction(doubleImage.GetPointer());
| |
| | |
| // Fails the concept check
| |
| // typedef itk::Image<int, 2> IntImageType;
| |
| // IntImageType::Pointer intImage = IntImageType::New();
| |
| // MyFunction(intImage.GetPointer());
| |
| | |
| // Fails the concept check
| |
| // typedef itk::Image<unsigned char, 2> UCharImageType;
| |
| // UCharImageType::Pointer ucharImage = UCharImageType::New();
| |
| // MyFunction(ucharImage.GetPointer());
| |
| | |
| return EXIT_SUCCESS;
| |
| }
| |
| | |
| </source>
| |
| | |
| {{ITKCMakeLists|{{SUBPAGENAME}}}}
| |