Fix build issues with C++20

- "ISO C++20 considers use of overloaded operator!= to be ambiguous
despite there being a unique best viable function with non-reversed
arguments"

- std::erase(std::vector, ...) takes preference over Utils::erase if not
fully qualified

Fixes: QTCREATORBUG-25598
Change-Id: Ib9d0574ff46d2ab415437c0c044c51e8c9f37caa
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
Eike Ziller
2021-04-19 10:15:01 +02:00
parent f31d583081
commit c2e4f9f2a2
5 changed files with 21 additions and 10 deletions

View File

@@ -82,6 +82,16 @@ public:
return !(first == second); return !(first == second);
} }
friend bool operator==(const FileNameEntry &first, const FileNameView &second)
{
return first.directoryId == second.directoryId && first.fileName == second.fileName;
}
friend bool operator!=(const FileNameEntry &first, const FileNameView &second)
{
return !(first == second);
}
operator FileNameView() const { return {fileName, directoryId}; } operator FileNameView() const { return {fileName, directoryId}; }
operator Utils::SmallString() && { return std::move(fileName); } operator Utils::SmallString() && { return std::move(fileName); }

View File

@@ -82,8 +82,8 @@ class PeripheralRegisterValue final
{ {
public: public:
PeripheralRegisterValue(quint64 v = 0) : v(v) {} PeripheralRegisterValue(quint64 v = 0) : v(v) {}
bool operator==(const PeripheralRegisterValue &other) { return v == other.v; } bool operator==(const PeripheralRegisterValue &other) const { return v == other.v; }
bool operator!=(const PeripheralRegisterValue &other) { return !operator==(other); } bool operator!=(const PeripheralRegisterValue &other) const { return !operator==(other); }
bool fromString(const QString &string, PeripheralRegisterFormat fmt); bool fromString(const QString &string, PeripheralRegisterFormat fmt);
QString toString(int size, PeripheralRegisterFormat fmt) const; QString toString(int size, PeripheralRegisterFormat fmt) const;

View File

@@ -238,8 +238,9 @@ void KitManager::restoreKits()
kitsToCheck.clear(); kitsToCheck.clear();
// Remove replacement kits for which the original kit has turned up again. // Remove replacement kits for which the original kit has turned up again.
erase(resultList, [&resultList](const std::unique_ptr<Kit> &k) { Utils::erase(resultList, [&resultList](const std::unique_ptr<Kit> &k) {
return k->isReplacementKit() && contains(resultList, [&k](const std::unique_ptr<Kit> &other) { return k->isReplacementKit()
&& contains(resultList, [&k](const std::unique_ptr<Kit> &other) {
return other->id() == k->id() && other != k; return other->id() == k->id() && other != k;
}); });
}); });

View File

@@ -1630,7 +1630,7 @@ bool JsonArray::operator==(const JsonArray &other) const
return !other.a->length; return !other.a->length;
if (!other.a) if (!other.a)
return !a->length; return !a->length;
if (a->length != other.a->length) if (a->length.val != other.a->length.val)
return false; return false;
for (int i = 0; i < (int)a->length; ++i) { for (int i = 0; i < (int)a->length; ++i) {
@@ -2594,7 +2594,7 @@ bool JsonObject::operator==(const JsonObject &other) const
return !other.o->length; return !other.o->length;
if (!other.o) if (!other.o)
return !o->length; return !o->length;
if (o->length != other.o->length) if (o->length.val != other.o->length.val)
return false; return false;
for (uint32_t i = 0; i < o->length; ++i) { for (uint32_t i = 0; i < o->length; ++i) {

View File

@@ -71,12 +71,12 @@ public:
return DiagnosticSetIterator(cxTranslationUnit, cxDiagnosticSet, oldIndex); return DiagnosticSetIterator(cxTranslationUnit, cxDiagnosticSet, oldIndex);
} }
bool operator==(const DiagnosticSetIterator &other) bool operator==(const DiagnosticSetIterator &other) const
{ {
return index == other.index && cxDiagnosticSet == other.cxDiagnosticSet; return index == other.index && cxDiagnosticSet == other.cxDiagnosticSet;
} }
bool operator!=(const DiagnosticSetIterator &other) bool operator!=(const DiagnosticSetIterator &other) const
{ {
return index != other.index || cxDiagnosticSet != other.cxDiagnosticSet; return index != other.index || cxDiagnosticSet != other.cxDiagnosticSet;
} }