Skip to content

STYLE: Use default member initialization#324

Merged
hjmjohnson merged 1 commit intoInsightSoftwareConsortium:masterfrom
hjmjohnson:modernize-use-default-member-init
Dec 18, 2018
Merged

STYLE: Use default member initialization#324
hjmjohnson merged 1 commit intoInsightSoftwareConsortium:masterfrom
hjmjohnson:modernize-use-default-member-init

Conversation

@hjmjohnson
Copy link
Copy Markdown
Member

Converts a default constructor’s member initializers into the new
default member initializers in C++11. Other member initializers that match the
default member initializer are removed. This can reduce repeated code or allow
use of ‘= default’.

VIM FIXUP: :%s/({[^}][^}]})(\1)/\1/g

SRCDIR=/Users/johnsonhj/Dashboard/src/ITK #My local SRC
BLDDIR=/Users/johnsonhj/Dashboard/src/ITK-clang/ #My local BLD

cd /Users/johnsonhj/Dashboard/src/ITK-clang/
run-clang-tidy.py -extra-arg=-D__clang__ -checks=-,modernize-use-default-member-init -header-filter=. -fix

Converts a default constructor’s member initializers into the new
default member initializers in C++11. Other member initializers that match the
default member initializer are removed. This can reduce repeated code or allow
use of ‘= default’.

VIM FIXUP:  :%s/\({[^}][^}]*}\)\(\1\)*/\1/g

SRCDIR=/Users/johnsonhj/Dashboard/src/ITK #My local SRC
BLDDIR=/Users/johnsonhj/Dashboard/src/ITK-clang/ #My local BLD

cd /Users/johnsonhj/Dashboard/src/ITK-clang/
run-clang-tidy.py -extra-arg=-D__clang__ -checks=-*,modernize-use-default-member-init  -header-filter=.* -fix
@hjmjohnson hjmjohnson force-pushed the modernize-use-default-member-init branch from 76397f6 to a9a501e Compare December 17, 2018 22:27
Copy link
Copy Markdown
Contributor

@N-Dekker N-Dekker left a comment

Choose a reason for hiding this comment

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

Very impressive :-) OK, it does "only converts member initializers for built-in types, enums, and pointers", but I think it's a great improvement. Thank you, Hans!

Copy link
Copy Markdown
Member

@dzenanz dzenanz left a comment

Choose a reason for hiding this comment

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

Awesome!

Comment thread Modules/Core/Common/include/itkLoggerOutput.h
Comment thread Modules/Core/Common/src/itkMultiThreaderBase.cxx
@hjmjohnson hjmjohnson merged commit b21dbbb into InsightSoftwareConsortium:master Dec 18, 2018
m_Thickness( 1.0 ),
m_Normalize(false),
m_BrightCenter(false),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

An unnecessary (?) empty line.

m_IsInBoundsValid(false),
m_NeedToUseBoundaryCondition(false)
::ConstNeighborhoodIterator()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Another unnecessary (?) empty line.

m_ApertureAngleY( 0.0f ),
m_TopPlane( 0.0f ),
m_BottomPlane( 0.0f ),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Another unnecessary (?) empty line.

m_Order(1),
m_Spacing(1.0)
::GaussianDerivativeOperator()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Another unnecessary (?) empty line.

m_Scale( 1.0 ),
m_Normalized( false )
::GaussianSpatialFunction()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Another unnecessary (?) empty line (etc. etc).

@hjmjohnson
Copy link
Copy Markdown
Member Author

@N-Dekker The automated tools have this side effect. I'm slowly working on a separate patch to clean those up. It also identifies several places where constructors can now be set to "= default' in the .h file instead of showing up in the .hxx files.

That work is something that I hope a new developer can work on.

@hjmjohnson hjmjohnson deleted the modernize-use-default-member-init branch October 23, 2019 13:30
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.

3 participants