CppEditor: Use a hidden friend to compare BaseEditorDocumentParser::Configuration

Posh, and avoids an upcoming warning with C++20:

/data/dev/creator/src/plugins/clangcodemodel/clangdclient.cpp:907:40: warning: C++20 says that these are ambiguous, even though the second is reversed:
In file included from /data/dev/creator/src/plugins/clangcodemodel/clangdclient.h:6,
                 from /data/dev/creator/src/plugins/clangcodemodel/clangdclient.cpp:4:
/data/dev/creator/src/plugins/cppeditor/baseeditordocumentparser.h:37:14: note: candidate 1: 'bool CppEditor::BaseEditorDocumentParser::Configuration::operator==(const CppEditor::BaseEditorDocumentParser::Configuration&)'
/data/dev/creator/src/plugins/cppeditor/baseeditordocumentparser.h:37:14: note: candidate 2: 'bool CppEditor::BaseEditorDocumentParser::Configuration::operator==(const CppEditor::BaseEditorDocumentParser::Configuration&)' (reversed)
/data/dev/creator/src/plugins/cppeditor/baseeditordocumentparser.h:37:14: note: try making the operator a 'const' member function

Change-Id: I98ed9d907b673b9353f540bab2ff7239e018b4f2
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
hjk
2024-02-09 15:18:40 +01:00
parent 4d9fe5572d
commit 354f50f258

View File

@@ -34,11 +34,11 @@ public:
QByteArray editorDefines;
QString preferredProjectPartId;
bool operator==(const Configuration &other)
friend bool operator==(const Configuration &left, const Configuration &right)
{
return usePrecompiledHeaders == other.usePrecompiledHeaders
&& editorDefines == other.editorDefines
&& preferredProjectPartId == other.preferredProjectPartId;
return left.usePrecompiledHeaders == right.usePrecompiledHeaders
&& left.editorDefines == right.editorDefines
&& left.preferredProjectPartId == right.preferredProjectPartId;
}
};