# ShapedNeighborhoodIterator\<\>::ConstIterator': is not a legal base class?

**URL:** https://discourse.itk.org/t/shapedneighborhooditerator-constiterator-is-not-a-legal-base-class/6665
**Category:** Engineering
**Created:** [May 29, 2024, 1:54pm UTC](https://discourse.itk.org/t/shapedneighborhooditerator-constiterator-is-not-a-legal-base-class/6665 "2024-05-29T13:54:58Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [May 29, 2024, 1:54pm UTC](https://discourse.itk.org/t/shapedneighborhooditerator-constiterator-is-not-a-legal-base-class/6665/1 "2024-05-29T13:54:58Z")

</div>

I am trying to build a Slicer CLI with C++20 settings, and I am running into:

`M:\a\Sd\ITK\Modules\Core\Common\include\itkShapedNeighborhoodIterator.h(182,28): error C2516: 'slicer_itk::ShapedNeighborhoodIterator<TImage,TBoundaryCondition>::ConstIterator': is not a legal base class`

The error persists even after I remove `#include "itkShapedNeighborhoodIterator.h"`. The program builds fine outside of Slicer (with vanilla ITK and C++20). Did anyone encounter anything similar?

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [May 31, 2024, 4:59pm UTC](https://discourse.itk.org/t/shapedneighborhooditerator-constiterator-is-not-a-legal-base-class/6665/2 "2024-05-31T16:59:40Z")

</div>

I did not get to the bottom of this error. Instead I decided to update ITK version within Slicer. My draft PR is here:

> <https://github.com/Slicer/Slicer/pull/7771>
>
> Pending merge of the following PRs:
> https://github.com/commontk/CTK/pull/1208
> …https://github.com/Slicer/SlicerExecutionModel/pull/139
> https://github.com/BRAINSia/BRAINSTools/pull/534
> I will set the correct upstreams instead of my forks.

---

<div class="post-metadata">

### Author: ![Jiang\_Sirenn](https://discourse.itk.org/user_avatar/discourse.itk.org/jiang_sirenn/32/4135_2.png) [@Jiang\_Sirenn](https://discourse.itk.org/u/Jiang_Sirenn)
#### Post date: [June 16, 2024, 11:54am UTC](https://discourse.itk.org/t/shapedneighborhooditerator-constiterator-is-not-a-legal-base-class/6665/3 "2024-06-16T11:54:56Z")

</div>

I have encountered the same problem and don’t know how to solve it. Have you solved it now？  
this error：  
error C2516: “itk::ShapedNeighborhoodIterator\<TImage,TBoundaryCondition\>::ConstIterator”: The error persists Demo D:\ITK\ITK\_debug\include\ITK-5.3\itkShapedNeighborhoodIterator.h 182

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [June 17, 2024, 12:41pm UTC](https://discourse.itk.org/t/shapedneighborhooditerator-constiterator-is-not-a-legal-base-class/6665/4 "2024-06-17T12:41:21Z")

</div>

I have not solved it. I did not even narrow it down to as what causes it.

---

<div class="post-metadata">

### Author: ![Jiang\_Sirenn](https://discourse.itk.org/user_avatar/discourse.itk.org/jiang_sirenn/32/4135_2.png) [@Jiang\_Sirenn](https://discourse.itk.org/u/Jiang_Sirenn)
#### Post date: [June 18, 2024, 5:12am UTC](https://discourse.itk.org/t/shapedneighborhooditerator-constiterator-is-not-a-legal-base-class/6665/5 "2024-06-18T05:12:46Z")

</div>

I am trying to compile version 5.1rc03 to see if the same issue occurs, and I look forward to your reply.
