Seeing the same error with ITK 5.3.0 release:
1>C:\itk\src-5.3.0\Modules\Core\Common\include\itkShapedNeighborhoodIterator.h(183,1): error C2516: 'itk::ShapedNeighborhoodIterator<TImage,TBoundaryCondition>::ConstIterator': is not a legal base class
1>C:\itk\src-5.3.0\Modules\Core\Common\include\itkShapedNeighborhoodIterator.h(171,3): message : see declaration of 'itk::ShapedNeighborhoodIterator<TImage,TBoundaryCondition>::ConstIterator'
1>C:\itk\src-5.3.0\Modules\Core\Common\include\itkShapedNeighborhoodIterator.h(209,1): message : see reference to class template instantiation 'itk::ShapedNeighborhoodIterator<TImage,TBoundaryCondition>::Iterator' being compiled
1>C:\itk\src-5.3.0\Modules\Core\Common\include\itkShapedNeighborhoodIterator.h(265,2): message : see reference to class template instantiation 'itk::ShapedNeighborhoodIterator<TImage,TBoundaryCondition>' being compiled
I’m using Visual Studio 2022 to compile, and I’m not using the ShapedNeighborhoodIterator
directly.
I get the error in the compilation of several files in our larger project (which compiles perfectly fine with ITK 5.2.x); I have tried hard (but have failed so far) in extracting a minimal example where this error occurs; I suppose it might come from a conflict resulting from pulling in a bunch of different ITK header files in the wrong order?
I do not even understand what the error means exactly - Microsoft Learn suggests this happens for example when the thing given as base class is not a class, or only forward-declared using typedef? I suppose in this case it would be some problem with template resolution?
Any hints on how I could narrow down where exactly the error is coming from? I have experimented with the “ShowIncludes” feature in Visual Studio, but that just shows me that for our large project, I get above error in between
1>Note: including file: C:\itk\src-5.3.0\Modules\Core\Common\include\itkConstShapedNeighborhoodIterator.hxx
and
1>Note: including file: C:\itk\src-5.3.0\Modules\Core\Common\include\itkShapedNeighborhoodIterator.hxx
while for the minimal example using the same filter pulling in the include (e.g. itkMorphologicalWatershedImageFilter, itkSignedMaurerDistanceMapImageFilter, itkBinaryFillholeImageFilter, …), I don’t get that error…