Qt6: QList<T>operator== requires const T::operator== #116
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.
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.