Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update override and virtual function designations." #184

Merged
merged 4 commits into from
Mar 17, 2025

Conversation

hjmjohnson
Copy link
Member

  • ENH: Revert Uses with "itk-branch: master" clang-format linter"
  • STYLE: Use override statements for C++11
  • ENH: Use matching types for comparision.
  • STYLE: Enforce ITK clang-format style.

Describe function overrides using the override keyword from C++11.

-----
https://stackoverflow.com/questions/39932391/virtual-override-or-both-c
When you override a function you don't technically need to write either virtual
or override.

The original base class declaration needs the keyword virtual to mark it as
virtual.

In the derived class the function is virtual by way of having the ¹same type as
the base class function.

However, an override can help avoid bugs by producing a compilation error when
the intended override isn't technically an override. For instance, the function
type isn't exactly like the base class function. Or that a maintenance of the
base class changes that function's type, e.g. adding a defaulted argument.

In the same way, a virtual keyword in the derived class can make such a bug
more subtle by ensuring that the function is still virtual in the further
derived classes.

So the general advice is,

Use virtual for the base class function declaration.  This is technically
necessary.

Use override (only) for a derived class' override.  This helps maintenance.
-----

Remove 'virtual' is implied when 'override' is specified, so remove the
redundant specification.

cd ${BLDDIR}
run-clang-tidy.py -extra-arg=-D__clang__ -checks=-*,modernize-use-override  -header-filter=.* -fix
@hjmjohnson hjmjohnson requested a review from dzenanz March 15, 2025 00:37
@hjmjohnson hjmjohnson self-assigned this Mar 15, 2025
@hjmjohnson
Copy link
Member Author

The failing build is unrelated to the changes in this PR.

Searching for wheels matching pattern dist/itk_*cp310*manylinux_2_28*aarch64.whl
ERROR    InvalidDistribution: Cannot find file (or expand pattern):             
         'dist/itk_*cp310*manylinux_2_28*aarch64.whl'                           
Error: Process completed with exit code 1.

@hjmjohnson hjmjohnson requested a review from aylward March 16, 2025 01:02
Use the formatting style of ITK 6+ with
clang-format-19 config.
@hjmjohnson hjmjohnson force-pushed the test-clang-format-ci branch from 4155c10 to 0bc2f82 Compare March 16, 2025 16:53
@dzenanz dzenanz merged commit 5138bce into main Mar 17, 2025
45 checks passed
@dzenanz dzenanz deleted the test-clang-format-ci branch March 17, 2025 12:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants