summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools
diff options
context:
space:
mode:
authorSona Kurazyan <sona.kurazyan@qt.io>2021-09-01 15:33:13 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-09-07 16:00:08 +0000
commitc315583a82eac39bce6feb0f5f4d4f6036b01611 (patch)
tree82c55f8448ba41f04e35ff175beb13cde72b9780 /src/corelib/tools
parent8f52022bbdd6aae40539191ce9db8b87328fe5b6 (diff)
Fix compilation for recursive Qt containers
The operator checks cause compilation errors when trying to check for their existence for recursive containers. This happens because of trying to check for the operators on the template parameter type(s), that inherit from the container itself, which leads to compilation errors. Introduced alternative versions of the operator checks (with _container suffix), that first check if the container is recursive, i.e. any of its template parameter types inherits from the given container, and skips the operator check, if that's the case. The fix is done for all Qt container types that had the problem, except for QVarLengthArray and QContiguousCache, which don't compile with recursive parameter types for unrelated reasons. Fixes: QTBUG-91707 Change-Id: Ia1e7240b4ce240c1c44f00ca680717d182df7550 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit 9f13842fe61541cb8ab9822174ea963e418b5537) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src/corelib/tools')
-rw-r--r--src/corelib/tools/qhash.h4
-rw-r--r--src/corelib/tools/qlist.h12
-rw-r--r--src/corelib/tools/qmap.h8
-rw-r--r--src/corelib/tools/qset.h4
4 files changed, 14 insertions, 14 deletions
diff --git a/src/corelib/tools/qhash.h b/src/corelib/tools/qhash.h
index 38f23d822f..9145891faf 100644
--- a/src/corelib/tools/qhash.h
+++ b/src/corelib/tools/qhash.h
@@ -820,7 +820,7 @@ public:
void swap(QHash &other) noexcept { qSwap(d, other.d); }
template <typename U = T>
- QTypeTraits::compare_eq_result<U> operator==(const QHash &other) const noexcept
+ QTypeTraits::compare_eq_result_container<QHash, U> operator==(const QHash &other) const noexcept
{
if (d == other.d)
return true;
@@ -836,7 +836,7 @@ public:
return true;
}
template <typename U = T>
- QTypeTraits::compare_eq_result<U> operator!=(const QHash &other) const noexcept
+ QTypeTraits::compare_eq_result_container<QHash, U> operator!=(const QHash &other) const noexcept
{ return !(*this == other); }
inline qsizetype size() const noexcept { return d ? qsizetype(d->size) : 0; }
diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h
index ddce07bbb7..0329dd37da 100644
--- a/src/corelib/tools/qlist.h
+++ b/src/corelib/tools/qlist.h
@@ -290,7 +290,7 @@ public:
void swap(QList<T> &other) noexcept { qSwap(d, other.d); }
template <typename U = T>
- QTypeTraits::compare_eq_result<U> operator==(const QList &other) const
+ QTypeTraits::compare_eq_result_container<QList, U> operator==(const QList &other) const
{
if (size() != other.size())
return false;
@@ -301,13 +301,13 @@ public:
return d->compare(begin(), other.begin(), size());
}
template <typename U = T>
- QTypeTraits::compare_eq_result<U> operator!=(const QList &other) const
+ QTypeTraits::compare_eq_result_container<QList, U> operator!=(const QList &other) const
{
return !(*this == other);
}
template <typename U = T>
- QTypeTraits::compare_lt_result<U> operator<(const QList &other) const
+ QTypeTraits::compare_lt_result_container<QList, U> operator<(const QList &other) const
noexcept(noexcept(std::lexicographical_compare<typename QList<U>::const_iterator,
typename QList::const_iterator>(
std::declval<QList<U>>().begin(), std::declval<QList<U>>().end(),
@@ -318,21 +318,21 @@ public:
}
template <typename U = T>
- QTypeTraits::compare_lt_result<U> operator>(const QList &other) const
+ QTypeTraits::compare_lt_result_container<QList, U> operator>(const QList &other) const
noexcept(noexcept(other < std::declval<QList<U>>()))
{
return other < *this;
}
template <typename U = T>
- QTypeTraits::compare_lt_result<U> operator<=(const QList &other) const
+ QTypeTraits::compare_lt_result_container<QList, U> operator<=(const QList &other) const
noexcept(noexcept(other < std::declval<QList<U>>()))
{
return !(other < *this);
}
template <typename U = T>
- QTypeTraits::compare_lt_result<U> operator>=(const QList &other) const
+ QTypeTraits::compare_lt_result_container<QList, U> operator>=(const QList &other) const
noexcept(noexcept(std::declval<QList<U>>() < other))
{
return !(*this < other);
diff --git a/src/corelib/tools/qmap.h b/src/corelib/tools/qmap.h
index d5f6b91ba8..57a964f29f 100644
--- a/src/corelib/tools/qmap.h
+++ b/src/corelib/tools/qmap.h
@@ -277,7 +277,7 @@ public:
}
template <typename AKey = Key, typename AT = T> friend
- QTypeTraits::compare_eq_result<AKey, AT> operator==(const QMap &lhs, const QMap &rhs)
+ QTypeTraits::compare_eq_result_container<QMap, AKey, AT> operator==(const QMap &lhs, const QMap &rhs)
{
if (lhs.d == rhs.d)
return true;
@@ -288,7 +288,7 @@ public:
}
template <typename AKey = Key, typename AT = T> friend
- QTypeTraits::compare_eq_result<AKey, AT> operator!=(const QMap &lhs, const QMap &rhs)
+ QTypeTraits::compare_eq_result_container<QMap, AKey, AT> operator!=(const QMap &lhs, const QMap &rhs)
{
return !(lhs == rhs);
}
@@ -905,7 +905,7 @@ public:
}
template <typename AKey = Key, typename AT = T> friend
- QTypeTraits::compare_eq_result<AKey, AT> operator==(const QMultiMap &lhs, const QMultiMap &rhs)
+ QTypeTraits::compare_eq_result_container<QMultiMap, AKey, AT> operator==(const QMultiMap &lhs, const QMultiMap &rhs)
{
if (lhs.d == rhs.d)
return true;
@@ -916,7 +916,7 @@ public:
}
template <typename AKey = Key, typename AT = T> friend
- QTypeTraits::compare_eq_result<AKey, AT> operator!=(const QMultiMap &lhs, const QMultiMap &rhs)
+ QTypeTraits::compare_eq_result_container<QMultiMap, AKey, AT> operator!=(const QMultiMap &lhs, const QMultiMap &rhs)
{
return !(lhs == rhs);
}
diff --git a/src/corelib/tools/qset.h b/src/corelib/tools/qset.h
index 681ce9cbe2..565b8b5691 100644
--- a/src/corelib/tools/qset.h
+++ b/src/corelib/tools/qset.h
@@ -72,10 +72,10 @@ public:
inline void swap(QSet<T> &other) noexcept { q_hash.swap(other.q_hash); }
template <typename U = T>
- QTypeTraits::compare_eq_result<U> operator==(const QSet<T> &other) const
+ QTypeTraits::compare_eq_result_container<QSet, U> operator==(const QSet<T> &other) const
{ return q_hash == other.q_hash; }
template <typename U = T>
- QTypeTraits::compare_eq_result<U> operator!=(const QSet<T> &other) const
+ QTypeTraits::compare_eq_result_container<QSet, U> operator!=(const QSet<T> &other) const
{ return q_hash != other.q_hash; }
inline qsizetype size() const { return q_hash.size(); }