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

Qt6: QList<T>operator== requires const T::operator== #116

Merged
merged 1 commit into from
Oct 3, 2023
Merged

Qt6: QList<T>operator== requires const T::operator== #116

merged 1 commit into from
Oct 3, 2023

Conversation

jbowler
Copy link
Contributor

@jbowler jbowler commented Oct 3, 2023

This causes a g++ compile error in codemodel.cpp (the error message is extremely confusing). It "works" in Qt5 but adding the "const" in the relevant places does not break the compile. Therefore:

bool TypeInfo::operator==(const TypeInfo&)

does not modify the LHS; this means that adding the const is safe (there would be a compile error if somoething in the implementation did modify part of the LHS).

It makes sense to me that Qt6 would do something to prevent an == operator with a mutable LHS. So far as I can see QList would have to make a complete copy of the LHS under some circumstances resulting in a potentially significant performance hit (depending on the complexity of the type involved).

This is a harmless but possibly beneficial change to both 'master' and 'qt6' branches.

This causes a g++ compile error in codemodel.cpp (the error message is
extremely confusing).  It "works" in Qt5 but adding the "const" in the
relevant places does not break the compile.  Therefore:

bool TypeInfo::operator==(const TypeInfo&)

does not modify the LHS; this means that adding the const is safe (there
would be a compile error if somoething in the implementation did modify
part of the LHS).

It makes sense to me that Qt6 would do something to prevent an ==
operator with a mutable LHS.  So far as I can see QList would have to
make a complete copy of the LHS under some circumstances resulting in a
potentially significant performance hit (depending on the complexity of
the type involved).

This is a harmless but possibly beneficial change to both 'master' and
'qt6' branches.

Signed-off-by: John Bowler <jbowler@acm.org>
Copy link
Contributor

@mrbean-bremen mrbean-bremen left a comment

Choose a reason for hiding this comment

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

👍🏼

@mrbean-bremen mrbean-bremen merged commit 6793f36 into MeVisLab:qt6 Oct 3, 2023
11 checks passed
mrbean-bremen pushed a commit to mrbean-bremen/pythonqt that referenced this pull request Oct 29, 2023
- missing consta caused a g++ compile error
- adding the const is safe, as it does not modify the LHS
mrbean-bremen pushed a commit that referenced this pull request Oct 29, 2023
- missing consta caused a g++ compile error
- adding the const is safe, as it does not modify the LHS
mrbean-bremen pushed a commit that referenced this pull request Nov 1, 2023
- missing consta caused a g++ compile error
- adding the const is safe, as it does not modify the LHS
mrbean-bremen pushed a commit that referenced this pull request Nov 2, 2023
- missing consta caused a g++ compile error
- adding the const is safe, as it does not modify the LHS
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.

2 participants