Skip to content

COMP: Let NthElementPixelAccessor follow the Rule of Zero#5849

Merged
dzenanz merged 1 commit intoInsightSoftwareConsortium:mainfrom
N-Dekker:NthElementPixelAccessor-Rule-of-Zero
Mar 3, 2026
Merged

COMP: Let NthElementPixelAccessor follow the Rule of Zero#5849
dzenanz merged 1 commit intoInsightSoftwareConsortium:mainfrom
N-Dekker:NthElementPixelAccessor-Rule-of-Zero

Conversation

@N-Dekker
Copy link
Copy Markdown
Contributor

@N-Dekker N-Dekker commented Mar 2, 2026

Removed its user-declared defaulted default-constructor and assignment operator, in order to address C++20 warnings, saying (on Linux/GCC 11.4.0):

warning: implicitly-declared 'constexpr NthElementPixelAccessor::NthElementPixelAccessor(const NthElementPixelAccessor&)' is deprecated [-Wdeprecated-copy]

The warning can be found at https://open.cdash.org/builds/11081768/errors

Full text:

/.../s/Modules/Core/ImageAdaptors/include/itkNthElementPixelAccessor.h:208:3: note: because 'itk::NthElementPixelAccessor<float, itk::VariableLengthVector<float> >' has user-provided 'itk::NthElementPixelAccessor<TOutputPixelType, itk::VariableLengthVector<TPixelType> >& itk::NthElementPixelAccessor<TOutputPixelType, itk::VariableLengthVector<TPixelType> >::operator=(const itk::NthElementPixelAccessor<TOutputPixelType, itk::VariableLengthVector<TPixelType> >&) [with TOutputPixelType = float; TPixelType = float]'

/.../s/Modules/Core/ImageAdaptors/include/itkNthElementPixelAccessor.h:208:3: note: because 'itk::NthElementPixelAccessor<float, itk::VariableLengthVector<float> >' has user-provided 'itk::NthElementPixelAccessor<TOutputPixelType, itk::VariableLengthVector<TPixelType> >& itk::NthElementPixelAccessor<TOutputPixelType, itk::VariableLengthVector<TPixelType> >::operator=(const itk::NthElementPixelAccessor<TOutputPixelType, itk::VariableLengthVector<TPixelType> >&) [with TOutputPixelType = float; TPixelType = float]'  208 |   operator=(const NthElementPixelAccessor & accessor)
      |   ^~~~~~~~


/.../s/Modules/Core/Common/include/itkImageConstIterator.h:168:7: warning: implicitly-declared 'constexpr itk::NthElementPixelAccessor<float, itk::VariableLengthVector<float> >::NthElementPixelAccessor(const itk::NthElementPixelAccessor<float, itk::VariableLengthVector<float> >&)' is deprecated [-Wdeprecated-copy]

Removed its user-declared defaulted default-constructor and assignment operator,
in order to address C++20 warnings, saying (on Linux/GCC 11.4.0):

    warning: implicitly-declared 'constexpr NthElementPixelAccessor::NthElementPixelAccessor(const NthElementPixelAccessor&)' is deprecated [-Wdeprecated-copy]
@github-actions github-actions Bot added type:Compiler Compiler support or related warnings area:Core Issues affecting the Core module labels Mar 2, 2026
@N-Dekker N-Dekker marked this pull request as ready for review March 2, 2026 13:45
Comment on lines -105 to -106
NthElementPixelAccessor &
operator=(const NthElementPixelAccessor & accessor) = default;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even though I think the warning is helpful, I don't think the note that GCC added is entirely correct. It says:

note: because 'itk::NthElementPixelAccessor' has user-provided 'itk::NthElementPixelAccessor& itk::NthElementPixelAccessor::operator=(const itk::NthElementPixelAccessor&)

However, this operator= is only user-declared, it is not "user-provided"! 🤓

@dzenanz dzenanz merged commit 4fcd284 into InsightSoftwareConsortium:main Mar 3, 2026
17 of 18 checks passed
N-Dekker added a commit to N-Dekker/ITK that referenced this pull request Mar 9, 2026
Let the assignment operator be implicitly defaulted (compiler generated), for the
VariableLengthVector specific template specialization of NthElementPixelAccessor.

Aims to address warnings appearing on Linux/GCC 11.4.0 saying:

    warning: implicitly-declared 'constexpr NthElementPixelAccessor::NthElementPixelAccessor(const NthElementPixelAccessor&)' is deprecated [-Wdeprecated-copy]

Follow-up to pull request InsightSoftwareConsortium#5849
commit 00ead18
"COMP: Let NthElementPixelAccessor follow the Rule of Zero"
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:Compiler Compiler support or related warnings

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants