ITK: ImageScanlineConstIterator not working with RLEImage module in ITK 5.4 rc02
Description
Compile time error thrown when using itkRLEImage with filters such as BinaryThresholdImageFilter. It was complaining about “no viable constructor or deduction guide for deduction of template arguments of ‘ImageScanlineConstIterator’”
Steps to Reproduce
https://github.com/jilei-hao/RLETest/tree/main
Expected behavior
Code compiles without error.
Actual behavior
When compiling target RLEImageTest
[ 50%] Building CXX object CMakeFiles/RLETest.dir/main.cxx.o
In file included from /Users/jileihao/dev/sandbox/RLETest/main.cxx:9:
In file included from /Users/jileihao/dev/itk-dev/itk/Modules/Filtering/Thresholding/include/itkBinaryThresholdImageFilter.h:21:
In file included from /Users/jileihao/dev/itk-dev/itk/Modules/Core/Common/include/itkUnaryFunctorImageFilter.h:145:
/Users/jileihao/dev/itk-dev/itk/Modules/Core/Common/include/itkUnaryFunctorImageFilter.hxx:88:30: error: no viable constructor or deduction guide for deduction of template arguments of 'ImageScanlineConstIterator'
ImageScanlineConstIterator inputIt(inputPtr, inputRegionForThread);
^
/Users/jileihao/dev/itk-dev/itk/Modules/Filtering/Thresholding/include/itkBinaryThresholdImageFilter.h:221:3: note: in instantiation of member function 'itk::UnaryFunctorImageFilter<itk::RLEImage<short, 3>, itk::Image<float, 3>, itk::Functor::BinaryThreshold<short, float>>::DynamicThreadedGenerateData' requested here
BinaryThresholdImageFilter();
^
/Users/jileihao/dev/itk-dev/itk/Modules/Filtering/Thresholding/include/itkBinaryThresholdImageFilter.h:150:15: note: in instantiation of member function 'itk::BinaryThresholdImageFilter<itk::RLEImage<short, 3>, itk::Image<float, 3>>::BinaryThresholdImageFilter' requested here
itkNewMacro(Self);
^
/Users/jileihao/dev/sandbox/RLETest/main.cxx:50:91: note: in instantiation of member function 'itk::BinaryThresholdImageFilter<itk::RLEImage<short, 3>, itk::Image<float, 3>>::New' requested here
auto fltThreshold = itk::BinaryThresholdImageFilter<shortRLEImage, Float3DImageType>::New();
^
/Users/jileihao/dev/itk-dev/itk/Modules/Core/Common/include/itkImageScanlineConstIterator.h:106:3: note: candidate template ignored: substitution failure [with TImage = itk::RLEImage<short, 3>]: cannot reference member of primary template because deduced class template specialization 'ImageScanlineConstIterator<itk::RLEImage<short, 3>>' is instantiated from a partial specialization
ImageScanlineConstIterator(const TImage * ptr, const RegionType & region)
^ ~~~~~~~~~~
/Users/jileihao/dev/itk-dev/itk/Modules/Core/Common/include/itkImageScanlineConstIterator.h:267:1: note: candidate template ignored: could not match 'SmartPointer<type-parameter-0-0>' against 'const itk::RLEImage<short, 3> *'
ImageScanlineConstIterator(SmartPointer<TImage>, const typename TImage::RegionType &)
^
/Users/jileihao/dev/itk-dev/itk/Modules/Core/Common/include/itkImageScanlineConstIterator.h:119:3: note: candidate function template not viable: requires single argument 'it', but 2 arguments were provided
ImageScanlineConstIterator(const ImageIterator<TImage> & it)
^
/Users/jileihao/dev/itk-dev/itk/Modules/Core/Common/include/itkImageScanlineConstIterator.h:135:3: note: candidate function template not viable: requires single argument 'it', but 2 arguments were provided
ImageScanlineConstIterator(const ImageConstIterator<TImage> & it)
^
/Users/jileihao/dev/itk-dev/itk/Modules/Core/Common/include/itkImageScanlineConstIterator.h:64:27: note: candidate function template not viable: requires 1 argument, but 2 were provided
class ITK_TEMPLATE_EXPORT ImageScanlineConstIterator : public ImageConstIterator<TImage>
^
/Users/jileihao/dev/itk-dev/itk/Modules/Core/Common/include/itkImageScanlineConstIterator.h:97:3: note: candidate function template not viable: requires 0 arguments, but 2 were provided
ImageScanlineConstIterator()
^
1 error generated.
make[3]: *** [CMakeFiles/RLETest.dir/main.cxx.o] Error 1
make[2]: *** [CMakeFiles/RLETest.dir/all] Error 2
make[1]: *** [CMakeFiles/RLETest.dir/rule] Error 2
make: *** [RLETest] Error 2
When compiling target RLEIteratorTest
[ 50%] Building CXX object CMakeFiles/RLEIteratorTest.dir/RLEIteratorTest.cxx.o
/Users/jileihao/dev/sandbox/RLETest/RLEIteratorTest.cxx:13:35: error: no viable constructor or deduction guide for deduction of template arguments of 'ImageScanlineConstIterator'
itk::ImageScanlineConstIterator it2(constRLE, constRLE->GetLargestPossibleRegion());
^
/Users/jileihao/dev/itk-dev/itk/Modules/Core/Common/include/itkImageScanlineConstIterator.h:106:3: note: candidate template ignored: substitution failure [with TImage = itk::RLEImage<short, 3>]: cannot reference member of primary template because deduced class template specialization 'ImageScanlineConstIterator<itk::RLEImage<short, 3>>' is instantiated from a partial specialization
ImageScanlineConstIterator(const TImage * ptr, const RegionType & region)
^ ~~~~~~~~~~
/Users/jileihao/dev/itk-dev/itk/Modules/Core/Common/include/itkImageScanlineConstIterator.h:267:1: note: candidate template ignored: could not match 'SmartPointer<type-parameter-0-0>' against 'const itk::RLEImage<short, 3> *'
ImageScanlineConstIterator(SmartPointer<TImage>, const typename TImage::RegionType &)
^
/Users/jileihao/dev/itk-dev/itk/Modules/Core/Common/include/itkImageScanlineConstIterator.h:119:3: note: candidate function template not viable: requires single argument 'it', but 2 arguments were provided
ImageScanlineConstIterator(const ImageIterator<TImage> & it)
^
/Users/jileihao/dev/itk-dev/itk/Modules/Core/Common/include/itkImageScanlineConstIterator.h:135:3: note: candidate function template not viable: requires single argument 'it', but 2 arguments were provided
ImageScanlineConstIterator(const ImageConstIterator<TImage> & it)
^
/Users/jileihao/dev/itk-dev/itk/Modules/Core/Common/include/itkImageScanlineConstIterator.h:64:27: note: candidate function template not viable: requires 1 argument, but 2 were provided
class ITK_TEMPLATE_EXPORT ImageScanlineConstIterator : public ImageConstIterator<TImage>
^
/Users/jileihao/dev/itk-dev/itk/Modules/Core/Common/include/itkImageScanlineConstIterator.h:97:3: note: candidate function template not viable: requires 0 arguments, but 2 were provided
ImageScanlineConstIterator()
^
1 error generated.
make[3]: *** [CMakeFiles/RLEIteratorTest.dir/RLEIteratorTest.cxx.o] Error 1
make[2]: *** [CMakeFiles/RLEIteratorTest.dir/all] Error 2
make[1]: *** [CMakeFiles/RLEIteratorTest.dir/rule] Error 2
make: *** [RLEIteratorTest] Error 2
Reproducibility
100%
Versions
ITK 5.4-rc02 with Module_RLEImage=ON
Environment
MacOS 12.7.4, Apple Clang 14.0.0, CMake 3.25.2
Additional Information
About this issue
- Original URL
- State: closed
- Created 3 months ago
- Reactions: 1
- Comments: 26 (13 by maintainers)
Commits related to this issue
- COMP: UnaryFunctorImageFilter RLEImage support on Apple Clang With: ❯ c++ --version Apple clang version 15.0.0 (clang-1500.3.9.4) Target: arm64-apple-darwin23.3.0 Thread model: posix InstalledDir: /... — committed to thewtex/ITK by thewtex 3 months ago
- COMP: UnaryFunctorImageFilter RLEImage support on Apple Clang With: ❯ c++ --version Apple clang version 15.0.0 (clang-1500.3.9.4) Target: arm64-apple-darwin23.3.0 Thread model: posix InstalledDir: /... — committed to thewtex/ITK by thewtex 3 months ago
- COMP: Add compiler deduction guides RLEImage ImageScanlineConstIterator This addresses https://github.com/InsightSoftwareConsortium/ITK/issues/4537 In addition to SmartPointer arguments, we need a r... — committed to KitwareMedical/ITKRLEImage by thewtex 3 months ago
- COMP: Add compiler deduction guides RLEImage ImageScanlineConstIterator This addresses https://github.com/InsightSoftwareConsortium/ITK/issues/4537 In addition to SmartPointer arguments, we need a r... — committed to thewtex/ITKRLEImage by thewtex 3 months ago
- COMP: Add compiler deduction guides RLEImage ImageScanlineConstIterator This addresses https://github.com/InsightSoftwareConsortium/ITK/issues/4537 In addition to SmartPointer arguments, we need a r... — committed to thewtex/ITKRLEImage by thewtex 3 months ago
- COMP: Add compiler deduction guides RLEImage ImageScanlineConstIterator This addresses https://github.com/InsightSoftwareConsortium/ITK/issues/4537 In addition to SmartPointer arguments, we need a r... — committed to thewtex/ITKRLEImage by thewtex 3 months ago
- COMP: Add compiler deduction guides RLEImage ImageScanlineConstIterator This addresses https://github.com/InsightSoftwareConsortium/ITK/issues/4537 In addition to SmartPointer arguments, we need a r... — committed to KitwareMedical/ITKRLEImage by thewtex 3 months ago
@jilei-hao Thanks for trying the code that I put at https://godbolt.org/z/3zMceGezo ! Clearly that code does not (yet) reproduce the issue you found, even though I tried to make it similar! You’re getting a link error, which is fine, because the errors that you reported should have appeared before linking, during the compilation phase.
It would be really interesting to know when such errors do and do not occur. We need it in order to know how to properly use class template argument deduction (CTAD).
So it would be helpful if you or anyone is able to reproduce those compile errors at https://godbolt.org Possibly by doing some adjustments to https://godbolt.org/z/3zMceGezo
Closing this issue since it has been addressed by https://github.com/KitwareMedical/ITKRLEImage/pull/63 Thanks again for everyone’s prompt support!
@jilei-hao thanks for the reproducible test case.
Addressed in #4553.
To make the RLEIteratorTest.cxx compile, a similar fix has to be applied.
Just tried but it did not fix the issue.
Still the same error for the master branch. I’ll test on Windows and Linux. But making it work for Mac is also important for us.