qFuzzy(Compare|IsNull)(): mark as noexcept
These all cannot fail, so can and should be noexcept. Most were already. Found in API-review. [ChangeLog][QtCore/QtGui] All qFuzzyCompare() and qFuzzyIsNull() overloads are now noexcept. Pick-to: 6.8 Change-Id: I67a2981ea4af9be0370becf84103822fd766ab5e Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
This commit is contained in:
parent
5028ff12d6
commit
6a3a28236c
@ -366,22 +366,22 @@ template <typename T>
|
||||
constexpr inline const T &min(const T &a, const T &b) { return (a < b) ? a : b; }
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr bool qFuzzyCompare(double p1, double p2)
|
||||
[[nodiscard]] constexpr bool qFuzzyCompare(double p1, double p2) noexcept
|
||||
{
|
||||
return (qAbs(p1 - p2) * 1000000000000. <= QtPrivate::min(qAbs(p1), qAbs(p2)));
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr bool qFuzzyCompare(float p1, float p2)
|
||||
[[nodiscard]] constexpr bool qFuzzyCompare(float p1, float p2) noexcept
|
||||
{
|
||||
return (qAbs(p1 - p2) * 100000.f <= QtPrivate::min(qAbs(p1), qAbs(p2)));
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr bool qFuzzyIsNull(double d)
|
||||
[[nodiscard]] constexpr bool qFuzzyIsNull(double d) noexcept
|
||||
{
|
||||
return qAbs(d) <= 0.000000000001;
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr bool qFuzzyIsNull(float f)
|
||||
[[nodiscard]] constexpr bool qFuzzyIsNull(float f) noexcept
|
||||
{
|
||||
return qAbs(f) <= 0.00001f;
|
||||
}
|
||||
|
@ -735,7 +735,7 @@ QMatrix4x4 operator/(const QMatrix4x4& matrix, float divisor)
|
||||
Returns \c true if \a m1 and \a m2 are equal, allowing for a small
|
||||
fuzziness factor for floating-point comparisons; false otherwise.
|
||||
*/
|
||||
bool qFuzzyCompare(const QMatrix4x4& m1, const QMatrix4x4& m2)
|
||||
bool qFuzzyCompare(const QMatrix4x4& m1, const QMatrix4x4& m2) noexcept
|
||||
{
|
||||
return qFuzzyCompare(m1.m[0][0], m2.m[0][0]) &&
|
||||
qFuzzyCompare(m1.m[0][1], m2.m[0][1]) &&
|
||||
|
@ -93,7 +93,7 @@ public:
|
||||
friend QMatrix4x4 operator*(const QMatrix4x4& matrix, float factor);
|
||||
friend Q_GUI_EXPORT QMatrix4x4 operator/(const QMatrix4x4& matrix, float divisor);
|
||||
|
||||
friend Q_GUI_EXPORT bool qFuzzyCompare(const QMatrix4x4& m1, const QMatrix4x4& m2);
|
||||
friend Q_GUI_EXPORT bool qFuzzyCompare(const QMatrix4x4& m1, const QMatrix4x4& m2) noexcept;
|
||||
|
||||
#ifndef QT_NO_VECTOR3D
|
||||
void scale(const QVector3D& vector);
|
||||
|
@ -304,7 +304,7 @@ inline QTransform &QTransform::operator-=(qreal num)
|
||||
|
||||
QT_WARNING_POP
|
||||
|
||||
inline bool qFuzzyCompare(const QTransform& t1, const QTransform& t2)
|
||||
inline bool qFuzzyCompare(const QTransform& t1, const QTransform& t2) noexcept
|
||||
{
|
||||
return qFuzzyCompare(t1.m11(), t2.m11())
|
||||
&& qFuzzyCompare(t1.m12(), t2.m12())
|
||||
|
Loading…
x
Reference in New Issue
Block a user