Skip to content

Class template argument deduction (CTAD) for Image Iterators in Core/Common#5845

Draft
N-Dekker wants to merge 4 commits intoInsightSoftwareConsortium:mainfrom
N-Dekker:CTAD-ImageIteratorsGTest
Draft

Class template argument deduction (CTAD) for Image Iterators in Core/Common#5845
N-Dekker wants to merge 4 commits intoInsightSoftwareConsortium:mainfrom
N-Dekker:CTAD-ImageIteratorsGTest

Conversation

@N-Dekker
Copy link
Contributor

@N-Dekker N-Dekker commented Feb 27, 2026

Added support for class template argument deduction (CTAD) to all "traditional" ITK Image Iterators in "Core/Common". Added deduction guides that support argument deduction from a SmartPointer (an Image::Pointer or an Image::ConstPointer).

Replaced `ImageType` with `TImage` as argument type of constructors of
Image Iterators, in order to support class template argument deduction (CTAD).

Following pull request InsightSoftwareConsortium#4013
commit 1b14a34
"STYLE: Use TImage for CTAD supporting constructors ImageScanlineIterator"
Added class template argument deduction guides to the Image Iterator class
templates, in order to support passing a `SmartPointer` as constructor
argument.

Using Notepad++, Replace in Files, doing:

  Find: `(Image\w*ConstIterator\w*)(\(const TImage \* ptr, const RegionType & region\).+\r\n};)`
  Replace with: `$1$2\r\n\r\n// Deduction guide for class template argument deduction \(CTAD\).\r\ntemplate <typename TImage>\r\n$1\(SmartPointer<TImage>, const typename TImage::RegionType &\)\r\n  -> $1<std::remove_const_t<TImage>>;\r\n`

  Find: `(Image\w*Iterator\w*)(\(TImage \* ptr, const RegionType & region\).+\r\n};)`
  Replace with: `$1$2\r\n\r\n// Deduction guide for class template argument deduction \(CTAD\).\r\ntemplate <typename TImage>\r\n$1\(SmartPointer<TImage>, const typename TImage::RegionType &\)\r\n  -> $1<TImage>;\r\n`

  Filters: `itk*ConstIterator*.h`
  Directory: `D:\ITK\Modules\Core\Common\include`
  [v] Match case
  (*) Regular expression
  [v] . matches newline

Excluded the Scanline iterators, as they already have an CTAD guide.
This GTest tests Image Iterators in general, not just `ImageRegionIterator`.
Checks that the iterator class templates in "Core/Common" support class template
argument deduction (CTAD).
@github-actions github-actions bot added type:Infrastructure Infrastructure/ecosystem related changes, such as CMake or buildbots type:Testing Ensure that the purpose of a class is met/the results on a wide set of test cases are correct area:Core Issues affecting the Core module labels Feb 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:Core Issues affecting the Core module type:Infrastructure Infrastructure/ecosystem related changes, such as CMake or buildbots type:Testing Ensure that the purpose of a class is met/the results on a wide set of test cases are correct

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant