-
Notifications
You must be signed in to change notification settings - Fork 357
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
Modernize the codebase - check for nullptr #2496
Modernize the codebase - check for nullptr #2496
Conversation
Not sure why, but after the latest commit, I now double-checked both |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What can I say?!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JanVogelsang Looks good, thank you! In the next PR (replacing &&
, ||
, and !
with and
, or
and not
), it would be good to also remove superfluous parentheses in boolean expression, e.g. of to form (n1) and (n2)
.
And merging ... |
I could only find very few occurrences (~25) of redundant parentheses, but I think I got them all. PR is incoming as soon as all tests pass. |
This PR is based on PR #2493.
In the C++ standard it is defined that
if ( ptr != nullptr )
gives the same result asif ( ptr )
asptr
is converted to abool
in the latter case, which per standard evaluates totrue
only ifptr != nullptr
.We can therefore convert all occurrences of
if ( ptr != nullptr )
toif ( ptr )
and
if ( ptr == nullptr )
toif ( not ptr )
which makes it quite clear in which cases a pointer is expected to be valid and when not.