diff options
author | Ivan Solovev <ivan.solovev@qt.io> | 2022-07-06 16:49:35 +0200 |
---|---|---|
committer | Sona Kurazyan <sona.kurazyan@qt.io> | 2022-08-11 21:13:16 +0200 |
commit | df1db826cb93132c05215be8f1451327d0323b4b (patch) | |
tree | a326c3a4340936d49d163c345ce55eaa34a77ee0 /src/corelib/global/qnumeric.h | |
parent | fc3441101b201ae37fda899bf69b5b4ded790a26 (diff) |
Move qMin/qMax/qBound() to a separate qminmax.h header
Also replaced qMin() uses in qnumeric.h with QtPrivate::min().
Including qassert.h in qminmax.h leads to indirect include of qglobal.h
(through qcompilerdetection.h), which in turn leads to qMin() declaration
not being available at the point the compiler sees qFuzzyCompare()
definitions in qnumeric.h. This makes the headersclean build fail.
Task-number: QTBUG-99313
Change-Id: I824422698b06f94a4a62e2f19d4507c87f90334e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'src/corelib/global/qnumeric.h')
-rw-r--r-- | src/corelib/global/qnumeric.h | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/corelib/global/qnumeric.h b/src/corelib/global/qnumeric.h index 24fa782f06..9ecbbc712a 100644 --- a/src/corelib/global/qnumeric.h +++ b/src/corelib/global/qnumeric.h @@ -9,6 +9,7 @@ #endif #include <QtCore/qglobal.h> + #include <cmath> #include <limits> #include <type_traits> @@ -356,14 +357,19 @@ constexpr inline qint64 qRound64(float d) { return d >= 0.0f ? qint64(d + 0.5f) : qint64(d - 0.5f); } #endif +namespace QtPrivate { +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) { - return (qAbs(p1 - p2) * 1000000000000. <= qMin(qAbs(p1), qAbs(p2))); + return (qAbs(p1 - p2) * 1000000000000. <= QtPrivate::min(qAbs(p1), qAbs(p2))); } [[nodiscard]] constexpr bool qFuzzyCompare(float p1, float p2) { - return (qAbs(p1 - p2) * 100000.f <= qMin(qAbs(p1), qAbs(p2))); + return (qAbs(p1 - p2) * 100000.f <= QtPrivate::min(qAbs(p1), qAbs(p2))); } [[nodiscard]] constexpr bool qFuzzyIsNull(double d) |