-
Notifications
You must be signed in to change notification settings - Fork 964
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
Use some C++11 features #1774
Merged
Merged
Use some C++11 features #1774
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Make sure the dependencies point to the correct files, even if an out of tree build is used.
It's rare we use a compiler that has anything older as a default, but it does happen sometimes. So make sure to guarantee this so we can start using more modern constructs.
It's more readable than 0, and a bit safer than NULL, so let's try to follow modern norms.
We use the pointer to just store an identifier for the menu, but this is enough for gcc to think we are using 0 instead of nullptr and complain. Even an explicit cast isn't enough to silence it here for some reason.
The compiler can help out in making sure we are consistent in our use of nullptr rather than NULL.
Use the new "override" keyword to properly differentiate between new virtual methods, and existing virtual methods being overridden.
Make sure developers don't miss marking methods correctly.
Let's avoid reimplementing something basic that's available in the standard library. It also makes the code easier to read.
Clients cannot remove themselves from the list as we are iterating, so we don't need this complexity. If a client encounters a problem, it will only mark it self as closed and will be removed from the list at a later time.
These are often more readable as they avoid a lot of the boilerplate of iterating over fixed arrays or STL containers. Note that this change is very conservative to avoid noise in "git blame". Only loops where this is a clear improvement have been converted.
Remove redundant arguments where the method already has access to the relevant variable as an object attribute.
Store the name in a std::string to make things less complex as we don't need to be as careful about making sure the data is free():d.
These functions act only on the input parameters, so let's make them static to more clearly indicate that they do not act upon any object.
It's a source of confusion and possibly bugs to reuse the same variable name for multiple things.
Shadowing variable can easily lead to bugs, so let's enforce that this is not allowed.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Now that we've dropped some older distributions, we can start to assume better C++11 support in the compilers.
We shouldn't convert everything just out of principle as that adds a lot of needless noise. But there are some safety features (and cleanups) that can be interesting.