Skip to content
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 16 commits into from
Jun 24, 2024
Merged

Use some C++11 features #1774

merged 16 commits into from
Jun 24, 2024

Conversation

CendioOssman
Copy link
Member

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.

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.
@CendioOssman CendioOssman marked this pull request as ready for review June 24, 2024 12:23
@CendioOssman CendioOssman merged commit 1b6d559 into TigerVNC:master Jun 24, 2024
11 checks passed
@CendioOssman CendioOssman deleted the c++11 branch June 24, 2024 12:39
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.

1 participant