summaryrefslogtreecommitdiffstats
path: root/src/corelib/global/qglobal.h
diff options
context:
space:
mode:
authorIvan Solovev <ivan.solovev@qt.io>2022-07-06 16:49:35 +0200
committerSona Kurazyan <sona.kurazyan@qt.io>2022-08-11 21:13:16 +0200
commitdf1db826cb93132c05215be8f1451327d0323b4b (patch)
treea326c3a4340936d49d163c345ce55eaa34a77ee0 /src/corelib/global/qglobal.h
parentfc3441101b201ae37fda899bf69b5b4ded790a26 (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/qglobal.h')
-rw-r--r--src/corelib/global/qglobal.h68
1 files changed, 1 insertions, 67 deletions
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h
index 82c6e5e037..54ce2ff6fa 100644
--- a/src/corelib/global/qglobal.h
+++ b/src/corelib/global/qglobal.h
@@ -446,73 +446,6 @@ typedef void (*QFunctionPointer)();
# define Q_UNIMPLEMENTED() qWarning("Unimplemented code.")
#endif
-namespace QTypeTraits {
-
-namespace detail {
-template<typename T, typename U,
- typename = std::enable_if_t<std::is_arithmetic_v<T> && std::is_arithmetic_v<U> &&
- std::is_floating_point_v<T> == std::is_floating_point_v<U> &&
- std::is_signed_v<T> == std::is_signed_v<U> &&
- !std::is_same_v<T, bool> && !std::is_same_v<U, bool> &&
- !std::is_same_v<T, char> && !std::is_same_v<U, char>>>
-struct Promoted
-{
- using type = decltype(T() + U());
-};
-}
-
-template <typename T, typename U>
-using Promoted = typename detail::Promoted<T, U>::type;
-
-}
-
-template <typename T>
-constexpr inline const T &qMin(const T &a, const T &b) { return (a < b) ? a : b; }
-template <typename T>
-constexpr inline const T &qMax(const T &a, const T &b) { return (a < b) ? b : a; }
-template <typename T>
-constexpr inline const T &qBound(const T &min, const T &val, const T &max)
-{
- Q_ASSERT(!(max < min));
- return qMax(min, qMin(max, val));
-}
-template <typename T, typename U>
-constexpr inline QTypeTraits::Promoted<T, U> qMin(const T &a, const U &b)
-{
- using P = QTypeTraits::Promoted<T, U>;
- P _a = a;
- P _b = b;
- return (_a < _b) ? _a : _b;
-}
-template <typename T, typename U>
-constexpr inline QTypeTraits::Promoted<T, U> qMax(const T &a, const U &b)
-{
- using P = QTypeTraits::Promoted<T, U>;
- P _a = a;
- P _b = b;
- return (_a < _b) ? _b : _a;
-}
-template <typename T, typename U>
-constexpr inline QTypeTraits::Promoted<T, U> qBound(const T &min, const U &val, const T &max)
-{
- Q_ASSERT(!(max < min));
- return qMax(min, qMin(max, val));
-}
-template <typename T, typename U>
-constexpr inline QTypeTraits::Promoted<T, U> qBound(const T &min, const T &val, const U &max)
-{
- using P = QTypeTraits::Promoted<T, U>;
- Q_ASSERT(!(P(max) < P(min)));
- return qMax(min, qMin(max, val));
-}
-template <typename T, typename U>
-constexpr inline QTypeTraits::Promoted<T, U> qBound(const U &min, const T &val, const T &max)
-{
- using P = QTypeTraits::Promoted<T, U>;
- Q_ASSERT(!(P(max) < P(min)));
- return qMax(min, qMin(max, val));
-}
-
/*
Compilers which follow outdated template instantiation rules
require a class to have a comparison operator to exist when
@@ -704,6 +637,7 @@ QT_END_NAMESPACE
#include <QtCore/qenvironmentvariables.h>
#include <QtCore/qforeach.h>
#include <QtCore/qglobalstatic.h>
+#include <QtCore/qminmax.h>
#include <QtCore/qnumeric.h>
#include <QtCore/qoverload.h>
#include <QtCore/qtdeprecationmarkers.h>