Skip to content

ENH: Providing ITKv5 updates for C++11#7

Merged
hjmjohnson merged 3 commits intomasterfrom
ITKv5_20180128_p1
Feb 12, 2018
Merged

ENH: Providing ITKv5 updates for C++11#7
hjmjohnson merged 3 commits intomasterfrom
ITKv5_20180128_p1

Conversation

@hjmjohnson
Copy link
Copy Markdown
Collaborator

This pull request incorporates code changes
that happened in parallel with updating the
core ITK code to ITKv5.

Provide initial conversion of features to ITKv5.
Provide remove virtual and override

Use clang-tidy to add ITK_OVERRIDE, and to remove
redundant virtual on functions.

cd ../ITK;
clang-tidy -p ITK-clangtidy $find Modules/[A-J]*  -name *.cxx |fgrep -v ThirdParty) -checks=-*,modernize-use-override  -header-filter=.* -fix
clang-tidy -p ITK-clangtidy $(find Modules/[K-Z]*  -name *.cxx |fgrep -v ThirdParty) -checks=-*,modernize-use-override  -header-filter=.* -fix

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. E.g. that 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 is virtual in further
derived classes.

So the general advice is,

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

Use override (only) for a derived class' override.
This helps with maintenance.
git grep -l "ITK_OVERRIDE" |   fgrep -v itk_compiler_detection.h | fgrep -v CMakeLists.txt |fgrep -v .cmake |   xargs sed -i '' -e "s/ITK_OVERRIDE/override/g"
@hjmjohnson hjmjohnson merged commit 2920864 into master Feb 12, 2018
@hjmjohnson hjmjohnson deleted the ITKv5_20180128_p1 branch February 12, 2018 20:49
blowekamp added a commit to blowekamp/ITKSimpleITKFilters that referenced this pull request Jan 4, 2021
Add intial check in of maksed assign image filter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant