STYLE: Prefer C++11 zero initializer to ZeroValue#3950
Conversation
Prefer to use standard C++ language initializers to the itk::NumericValues<>::ZeroValue() initializers.
N-Dekker
left a comment
There was a problem hiding this comment.
Wonderful, thanks Hans! Did you use a regular expression to find and replace all those cases? If so, can you possibly still share the regular expression, either in the commit message or as a PR comment?
BTW, I would slightly reword the subject line, to mention {} explicitly, for example:
STYLE: Prefer C++11 `{}` initializer to NumericTraits::ZeroValue() call
But that's just a matter of style 😸 Approved anyway! 👍
Dropped the requirement to use NumericTraits for all numeric data member initialization. Following pull request InsightSoftwareConsortium/ITK#3950 by Hans Johnson.
|
Will the |
Hi @blowekamp Yes, |
|
@blowekamp To elaborate on your question, with the following user-defined types (below here), the data members of instances of Aggregate and DefaultedConstructor are properly zero-initialized by the form |
Replaced initialization by `NumericTraits<T>::ZeroValue()` with empty `{}`
initializers. Did so by Replace in Files, using regular expressions:
Find what: (\w+)([ ]+\w+) = NumericTraits<\1>::ZeroValue\(\);
Replace with: $1$2{};
Follow-up to pull request InsightSoftwareConsortium#3950
commmit ef5cc8c
"STYLE: Prefer C++11 zero initializer to ZeroValue", by Hans Johnson.
Replaced initialization by `NumericTraits<T>::ZeroValue()` with empty `{}`
initializers. Did so by Replace in Files, using regular expressions:
Find what: (\w+)([ ]+\w+) = NumericTraits<\1>::ZeroValue\(\);
Replace with: $1$2{};
Follow-up to pull request #3950
commmit ef5cc8c
"STYLE: Prefer C++11 zero initializer to ZeroValue", by Hans Johnson.
Prefer to use standard C++ language initializers to the itk::NumericValues<>::ZeroValue() initializers.
PR Checklist