serialization: remove incorrect noexcept on comparison operators [2/2]
This patch is about removing noexcept on functions that use Q_ASSERT. The argument is that in these cases Q_ASSERTs act as precondition checks, so we should probably follow the Lakos rule. Although, technically the change is fine, because the current implementation of Q_ASSERT is marked as noexcept(true), there are some ideas of changing that in future, so we should not be setting in stone something we can't change later. Found in 6.8 API review. Change-Id: I1d4aa228c713821c0ebbfc0f3b956d29fe652ed8 Reviewed-by: Marc Mutz <marc.mutz@qt.io> (cherry picked from commit 5ac15093dcbaf92ac166961f5e8bfe9418cc15c0) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
820f00693c
commit
48c8eef930
@ -98,14 +98,14 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Qt::strong_ordering compareThreeWay_helper(const Iterator &lhs,
|
static Qt::strong_ordering compareThreeWay_helper(const Iterator &lhs,
|
||||||
const Iterator &rhs) noexcept
|
const Iterator &rhs)
|
||||||
{
|
{
|
||||||
Q_ASSERT(lhs.item.d == rhs.item.d);
|
Q_ASSERT(lhs.item.d == rhs.item.d);
|
||||||
return Qt::compareThreeWay(lhs.item.i, rhs.item.i);
|
return Qt::compareThreeWay(lhs.item.i, rhs.item.i);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Qt::strong_ordering compareThreeWay_helper(const Iterator &lhs,
|
static Qt::strong_ordering compareThreeWay_helper(const Iterator &lhs,
|
||||||
const ConstIterator &rhs) noexcept
|
const ConstIterator &rhs)
|
||||||
{
|
{
|
||||||
Q_ASSERT(lhs.item.d == rhs.item.d);
|
Q_ASSERT(lhs.item.d == rhs.item.d);
|
||||||
return Qt::compareThreeWay(lhs.item.i, rhs.item.i);
|
return Qt::compareThreeWay(lhs.item.i, rhs.item.i);
|
||||||
@ -117,21 +117,21 @@ public:
|
|||||||
return comparesEqual_helper(lhs, rhs);
|
return comparesEqual_helper(lhs, rhs);
|
||||||
}
|
}
|
||||||
friend Qt::strong_ordering compareThreeWay(const Iterator &lhs,
|
friend Qt::strong_ordering compareThreeWay(const Iterator &lhs,
|
||||||
const Iterator &rhs) noexcept
|
const Iterator &rhs)
|
||||||
{
|
{
|
||||||
return compareThreeWay_helper(lhs, rhs);
|
return compareThreeWay_helper(lhs, rhs);
|
||||||
}
|
}
|
||||||
Q_DECLARE_STRONGLY_ORDERED(Iterator)
|
Q_DECLARE_STRONGLY_ORDERED_NON_NOEXCEPT(Iterator)
|
||||||
friend bool comparesEqual(const Iterator &lhs, const ConstIterator &rhs) noexcept
|
friend bool comparesEqual(const Iterator &lhs, const ConstIterator &rhs) noexcept
|
||||||
{
|
{
|
||||||
return comparesEqual_helper(lhs, rhs);
|
return comparesEqual_helper(lhs, rhs);
|
||||||
}
|
}
|
||||||
friend Qt::strong_ordering compareThreeWay(const Iterator &lhs,
|
friend Qt::strong_ordering compareThreeWay(const Iterator &lhs,
|
||||||
const ConstIterator &rhs) noexcept
|
const ConstIterator &rhs)
|
||||||
{
|
{
|
||||||
return compareThreeWay_helper(lhs, rhs);
|
return compareThreeWay_helper(lhs, rhs);
|
||||||
}
|
}
|
||||||
Q_DECLARE_STRONGLY_ORDERED(Iterator, ConstIterator)
|
Q_DECLARE_STRONGLY_ORDERED_NON_NOEXCEPT(Iterator, ConstIterator)
|
||||||
};
|
};
|
||||||
|
|
||||||
class ConstIterator {
|
class ConstIterator {
|
||||||
@ -202,7 +202,7 @@ public:
|
|||||||
return lhs.item.d == rhs.item.d && lhs.item.i == rhs.item.i;
|
return lhs.item.d == rhs.item.d && lhs.item.i == rhs.item.i;
|
||||||
}
|
}
|
||||||
static Qt::strong_ordering compareThreeWay_helper(const ConstIterator &lhs,
|
static Qt::strong_ordering compareThreeWay_helper(const ConstIterator &lhs,
|
||||||
const ConstIterator &rhs) noexcept
|
const ConstIterator &rhs)
|
||||||
{
|
{
|
||||||
Q_ASSERT(lhs.item.d == rhs.item.d);
|
Q_ASSERT(lhs.item.d == rhs.item.d);
|
||||||
return Qt::compareThreeWay(lhs.item.i, rhs.item.i);
|
return Qt::compareThreeWay(lhs.item.i, rhs.item.i);
|
||||||
@ -214,11 +214,11 @@ public:
|
|||||||
return comparesEqual_helper(lhs, rhs);
|
return comparesEqual_helper(lhs, rhs);
|
||||||
}
|
}
|
||||||
friend Qt::strong_ordering compareThreeWay(const ConstIterator &lhs,
|
friend Qt::strong_ordering compareThreeWay(const ConstIterator &lhs,
|
||||||
const ConstIterator &rhs) noexcept
|
const ConstIterator &rhs)
|
||||||
{
|
{
|
||||||
return compareThreeWay_helper(lhs, rhs);
|
return compareThreeWay_helper(lhs, rhs);
|
||||||
}
|
}
|
||||||
Q_DECLARE_STRONGLY_ORDERED(ConstIterator)
|
Q_DECLARE_STRONGLY_ORDERED_NON_NOEXCEPT(ConstIterator)
|
||||||
};
|
};
|
||||||
|
|
||||||
QCborMap() noexcept;
|
QCborMap() noexcept;
|
||||||
|
@ -137,14 +137,14 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Qt::strong_ordering compareThreeWay_helper(const iterator &lhs,
|
static Qt::strong_ordering compareThreeWay_helper(const iterator &lhs,
|
||||||
const iterator &rhs) noexcept
|
const iterator &rhs)
|
||||||
{
|
{
|
||||||
Q_ASSERT(lhs.item.d == rhs.item.d);
|
Q_ASSERT(lhs.item.d == rhs.item.d);
|
||||||
return Qt::compareThreeWay(lhs.item.index, rhs.item.index);
|
return Qt::compareThreeWay(lhs.item.index, rhs.item.index);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Qt::strong_ordering compareThreeWay_helper(const iterator &lhs,
|
static Qt::strong_ordering compareThreeWay_helper(const iterator &lhs,
|
||||||
const const_iterator &rhs) noexcept
|
const const_iterator &rhs)
|
||||||
{
|
{
|
||||||
Q_ASSERT(lhs.item.d == rhs.item.d);
|
Q_ASSERT(lhs.item.d == rhs.item.d);
|
||||||
return Qt::compareThreeWay(lhs.item.index, rhs.item.index);
|
return Qt::compareThreeWay(lhs.item.index, rhs.item.index);
|
||||||
@ -156,21 +156,21 @@ public:
|
|||||||
return comparesEqual_helper(lhs, rhs);
|
return comparesEqual_helper(lhs, rhs);
|
||||||
}
|
}
|
||||||
friend Qt::strong_ordering compareThreeWay(const iterator &lhs,
|
friend Qt::strong_ordering compareThreeWay(const iterator &lhs,
|
||||||
const iterator &rhs) noexcept
|
const iterator &rhs)
|
||||||
{
|
{
|
||||||
return compareThreeWay_helper(lhs, rhs);
|
return compareThreeWay_helper(lhs, rhs);
|
||||||
}
|
}
|
||||||
Q_DECLARE_STRONGLY_ORDERED(iterator)
|
Q_DECLARE_STRONGLY_ORDERED_NON_NOEXCEPT(iterator)
|
||||||
friend bool comparesEqual(const iterator &lhs, const const_iterator &rhs) noexcept
|
friend bool comparesEqual(const iterator &lhs, const const_iterator &rhs) noexcept
|
||||||
{
|
{
|
||||||
return comparesEqual_helper(lhs, rhs);
|
return comparesEqual_helper(lhs, rhs);
|
||||||
}
|
}
|
||||||
friend Qt::strong_ordering compareThreeWay(const iterator &lhs,
|
friend Qt::strong_ordering compareThreeWay(const iterator &lhs,
|
||||||
const const_iterator &rhs) noexcept
|
const const_iterator &rhs)
|
||||||
{
|
{
|
||||||
return compareThreeWay_helper(lhs, rhs);
|
return compareThreeWay_helper(lhs, rhs);
|
||||||
}
|
}
|
||||||
Q_DECLARE_STRONGLY_ORDERED(iterator, const_iterator)
|
Q_DECLARE_STRONGLY_ORDERED_NON_NOEXCEPT(iterator, const_iterator)
|
||||||
|
|
||||||
QJsonValueRef item;
|
QJsonValueRef item;
|
||||||
friend class QJsonArray;
|
friend class QJsonArray;
|
||||||
@ -230,7 +230,7 @@ public:
|
|||||||
return lhs.item.d == rhs.item.d && lhs.item.index == rhs.item.index;
|
return lhs.item.d == rhs.item.d && lhs.item.index == rhs.item.index;
|
||||||
}
|
}
|
||||||
static Qt::strong_ordering compareThreeWay_helper(const const_iterator &lhs,
|
static Qt::strong_ordering compareThreeWay_helper(const const_iterator &lhs,
|
||||||
const const_iterator &rhs) noexcept
|
const const_iterator &rhs)
|
||||||
{
|
{
|
||||||
Q_ASSERT(lhs.item.d == rhs.item.d);
|
Q_ASSERT(lhs.item.d == rhs.item.d);
|
||||||
return Qt::compareThreeWay(lhs.item.index, rhs.item.index);
|
return Qt::compareThreeWay(lhs.item.index, rhs.item.index);
|
||||||
@ -242,11 +242,11 @@ public:
|
|||||||
return comparesEqual_helper(lhs, rhs);
|
return comparesEqual_helper(lhs, rhs);
|
||||||
}
|
}
|
||||||
friend Qt::strong_ordering compareThreeWay(const const_iterator &lhs,
|
friend Qt::strong_ordering compareThreeWay(const const_iterator &lhs,
|
||||||
const const_iterator &rhs) noexcept
|
const const_iterator &rhs)
|
||||||
{
|
{
|
||||||
return compareThreeWay_helper(lhs, rhs);
|
return compareThreeWay_helper(lhs, rhs);
|
||||||
}
|
}
|
||||||
Q_DECLARE_STRONGLY_ORDERED(const_iterator)
|
Q_DECLARE_STRONGLY_ORDERED_NON_NOEXCEPT(const_iterator)
|
||||||
QJsonValueConstRef item;
|
QJsonValueConstRef item;
|
||||||
friend class QJsonArray;
|
friend class QJsonArray;
|
||||||
};
|
};
|
||||||
|
@ -152,13 +152,13 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Qt::strong_ordering compareThreeWay_helper(const iterator &lhs,
|
static Qt::strong_ordering compareThreeWay_helper(const iterator &lhs,
|
||||||
const iterator &rhs) noexcept
|
const iterator &rhs)
|
||||||
{
|
{
|
||||||
Q_ASSERT(lhs.item.d == rhs.item.d);
|
Q_ASSERT(lhs.item.d == rhs.item.d);
|
||||||
return Qt::compareThreeWay(lhs.item.index, rhs.item.index);
|
return Qt::compareThreeWay(lhs.item.index, rhs.item.index);
|
||||||
}
|
}
|
||||||
static Qt::strong_ordering compareThreeWay_helper(const iterator &lhs,
|
static Qt::strong_ordering compareThreeWay_helper(const iterator &lhs,
|
||||||
const const_iterator &rhs) noexcept
|
const const_iterator &rhs)
|
||||||
{
|
{
|
||||||
Q_ASSERT(lhs.item.d == rhs.item.d);
|
Q_ASSERT(lhs.item.d == rhs.item.d);
|
||||||
return Qt::compareThreeWay(lhs.item.index, rhs.item.index);
|
return Qt::compareThreeWay(lhs.item.index, rhs.item.index);
|
||||||
@ -170,22 +170,22 @@ public:
|
|||||||
return comparesEqual_helper(lhs, rhs);
|
return comparesEqual_helper(lhs, rhs);
|
||||||
}
|
}
|
||||||
friend Qt::strong_ordering compareThreeWay(const iterator &lhs,
|
friend Qt::strong_ordering compareThreeWay(const iterator &lhs,
|
||||||
const iterator &rhs) noexcept
|
const iterator &rhs)
|
||||||
{
|
{
|
||||||
return compareThreeWay_helper(lhs, rhs);
|
return compareThreeWay_helper(lhs, rhs);
|
||||||
}
|
}
|
||||||
Q_DECLARE_STRONGLY_ORDERED(iterator)
|
Q_DECLARE_STRONGLY_ORDERED_NON_NOEXCEPT(iterator)
|
||||||
|
|
||||||
friend bool comparesEqual(const iterator &lhs, const const_iterator &rhs) noexcept
|
friend bool comparesEqual(const iterator &lhs, const const_iterator &rhs) noexcept
|
||||||
{
|
{
|
||||||
return comparesEqual_helper(lhs, rhs);
|
return comparesEqual_helper(lhs, rhs);
|
||||||
}
|
}
|
||||||
friend Qt::strong_ordering compareThreeWay(const iterator &lhs,
|
friend Qt::strong_ordering compareThreeWay(const iterator &lhs,
|
||||||
const const_iterator &rhs) noexcept
|
const const_iterator &rhs)
|
||||||
{
|
{
|
||||||
return compareThreeWay_helper(lhs, rhs);
|
return compareThreeWay_helper(lhs, rhs);
|
||||||
}
|
}
|
||||||
Q_DECLARE_STRONGLY_ORDERED(iterator, const_iterator)
|
Q_DECLARE_STRONGLY_ORDERED_NON_NOEXCEPT(iterator, const_iterator)
|
||||||
};
|
};
|
||||||
friend class iterator;
|
friend class iterator;
|
||||||
|
|
||||||
@ -259,7 +259,7 @@ public:
|
|||||||
return lhs.item.d == rhs.item.d && lhs.item.index == rhs.item.index;
|
return lhs.item.d == rhs.item.d && lhs.item.index == rhs.item.index;
|
||||||
}
|
}
|
||||||
static Qt::strong_ordering compareThreeWay_helper(const const_iterator &lhs,
|
static Qt::strong_ordering compareThreeWay_helper(const const_iterator &lhs,
|
||||||
const const_iterator &rhs) noexcept
|
const const_iterator &rhs)
|
||||||
{
|
{
|
||||||
Q_ASSERT(lhs.item.d == rhs.item.d);
|
Q_ASSERT(lhs.item.d == rhs.item.d);
|
||||||
return Qt::compareThreeWay(lhs.item.index, rhs.item.index);
|
return Qt::compareThreeWay(lhs.item.index, rhs.item.index);
|
||||||
@ -271,11 +271,11 @@ public:
|
|||||||
return comparesEqual_helper(lhs, rhs);
|
return comparesEqual_helper(lhs, rhs);
|
||||||
}
|
}
|
||||||
friend Qt::strong_ordering compareThreeWay(const const_iterator &lhs,
|
friend Qt::strong_ordering compareThreeWay(const const_iterator &lhs,
|
||||||
const const_iterator &rhs) noexcept
|
const const_iterator &rhs)
|
||||||
{
|
{
|
||||||
return compareThreeWay_helper(lhs, rhs);
|
return compareThreeWay_helper(lhs, rhs);
|
||||||
}
|
}
|
||||||
Q_DECLARE_STRONGLY_ORDERED(const_iterator)
|
Q_DECLARE_STRONGLY_ORDERED_NON_NOEXCEPT(const_iterator)
|
||||||
};
|
};
|
||||||
friend class const_iterator;
|
friend class const_iterator;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user