ENH: Add C++ script to add in-class {} member initializers to ITK#3935
Conversation
|
Thanks for doing this @N-Dekker 💯, and also all the related PRs lately, and the PR to skip the CI for files that do no need to be tested. |
|
You're welcome @jhlegarreta I'm happy to see that it did not trigger a CI run 😃 You know I hesitated to place this script in the ITK git repository, because I did not want to add an extra maintenance burden. The script was meant to reduce maintenance in the first place! Once it is in here, people may do code clean-up's, fix typo's, upgrade the code to newer style guidelines or other compilers, etc. While I think ITK has more than enough code to maintain already! As a compromise, could we agree that this script does not need to be at the By the way, I may still make some small adjustments to the code, that's why it's still draft now. |
Niels, we ourselves are trying to maintain code that we did not write, so anybody in the open source community that is interested in ITK is more than welcome to improve the script if they need it. But in the first place, it can be very useful for e.g. remote modules. So even if you cannot devote time to maintain it further, I would keep it; it does not make sense to me to remove it for the next releases (for example, not all remotes may have time to apply the script by then).
Fine, I just wanted to thank you for the effort of doing these things. |
|
Is there much overlap with this an the "use-default-member-init" functionality of clang tidy? @N-Dekker Can you compare and contrast functionality? |
|
If we remove these scripts from master, they would be even harder to find than they are now. I vote to keep them where they are. We might even consider moving |
Thanks for asking @blowekamp I think this script (AddEmptyDefaultMemberInitializers.cxx) is complementary to the clang tidy "use-default-member-init" option. The clang-tidy option moves existing (C++98/03 style) member initializers from constructors to the corresponding C++11/C++14 in-class data member declaration. While the script adds in-class Note that Hans (@hjmjohnson) has already run the clang tidy option extensively: |
e5cb2e2 to
0cf8243
Compare
|
FYI Before merging, I would still like to extend the script to address lines of code that do not end with a semi-colon! Specifically: Because of the trailing comment, this data member is still ignored now, even if it should have a |
a79f662 to
f0189f3
Compare
The script that was used for the following pull requests: pull request InsightSoftwareConsortium#3851 "STYLE: Add in-class `{}` member initializers to objects created by New()" pull request InsightSoftwareConsortium#3913 "STYLE: Add in-class `{}` initializers to classes with virtual functions" pull request InsightSoftwareConsortium#3917 "STYLE: Add in-class `{}` initializers to classes with override = default" pull request InsightSoftwareConsortium#3941 "STYLE: Add in-class `{}` member initializers to 3-letter data members" pull request InsightSoftwareConsortium#3945 "STYLE: Add in-class `{}` member initializers having trailing comments"
f0189f3 to
35426ac
Compare
Ran "AddEmptyDefaultMemberInitializers" from pull request InsightSoftwareConsortium/ITK#3935 ("ENH: Add C++ script to add in-class `{}` member initializers to ITK") on the elastix source tree.
Ran "AddEmptyDefaultMemberInitializers" from pull request InsightSoftwareConsortium/ITK#3935 ("ENH: Add C++ script to add in-class `{}` member initializers to ITK") on the elastix source tree.
Ran "AddEmptyDefaultMemberInitializers" from pull request InsightSoftwareConsortium/ITK#3935 ("ENH: Add C++ script to add in-class `{}` member initializers to ITK") on the elastix source tree.
thewtex
left a comment
There was a problem hiding this comment.
Amazing to see C++ capable of what effectively only scripting languages could do in the past! 🎇
The script that was used for the following pull requests:
{}member initializers to objects created by New() #3851{}initializers to classes with virtual functions #3913{}initializers to classes with override = default #3917{}member initializers to 3-letter data members #3941{}member initializers having trailing comments #3945