Skip to content

Commit c846421

Browse files
authored
Merge pull request InsightSoftwareConsortium#6130 from N-Dekker/Deprecate-passing-const-image-to-ShapedNeighborhoodIterator-constructor
ENH: Deprecate passing a `const` image to ShapedNeighborhoodIterator
2 parents 51a5fdb + 821c65d commit c846421

1 file changed

Lines changed: 17 additions & 2 deletions

File tree

Modules/Core/Common/include/itkShapedNeighborhoodIterator.h

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
#include <vector>
2222
#include <list>
23+
#include <type_traits> // For add_const_t.
2324
#include "itkConstShapedNeighborhoodIterator.h"
2425

2526
namespace itk
@@ -219,10 +220,24 @@ class ITK_TEMPLATE_EXPORT ShapedNeighborhoodIterator
219220

220221
/** Constructor which establishes the region size, neighborhood, and image
221222
* over which to walk. */
222-
ShapedNeighborhoodIterator(const SizeType & radius, const ImageType * ptr, const RegionType & region)
223-
: Superclass(radius, const_cast<ImageType *>(ptr), region)
223+
ShapedNeighborhoodIterator(const SizeType & radius, ImageType * ptr, const RegionType & region)
224+
: Superclass(radius, ptr, region)
224225
{}
225226

227+
#ifndef ITK_FUTURE_LEGACY_REMOVE
228+
/** Constructor which establishes the region size, neighborhood, and image over which to walk.
229+
\deprecated This constructor is intended to be removed. For a `const` image, use ConstShapedNeighborhoodIterator
230+
instead! */
231+
ITK_FUTURE_DEPRECATED(
232+
"This constructor is intended to be removed. For a `const` image, use ConstShapedNeighborhoodIterator instead!")
233+
ShapedNeighborhoodIterator(const SizeType & radius, std::add_const_t<ImageType> * ptr, const RegionType & region)
234+
: Superclass(radius, ptr, region)
235+
{
236+
// Note: parameter type `std::add_const_t<ImageType> *` prevents accidental class template argument deduction
237+
// (CTAD).
238+
}
239+
#endif
240+
226241
// Expose the following methods from the superclass. This is a restricted
227242
// subset of the methods available for NeighborhoodIterator.
228243
using Superclass::SetPixel;

0 commit comments

Comments
 (0)