OSDN Git Service

move qRound() and qRound64() to qmath header
authorIvailo Monev <xakepa10@laimg.moc>
Tue, 21 May 2019 14:37:01 +0000 (14:37 +0000)
committerIvailo Monev <xakepa10@laimg.moc>
Tue, 21 May 2019 14:37:01 +0000 (14:37 +0000)
Signed-off-by: Ivailo Monev <xakepa10@laimg.moc>
src/core/global/qglobal.h.cmake
src/core/kernel/qmath.h
src/core/kernel/qvariant.cpp
src/core/tools/qdatetime.cpp
src/core/tools/qpoint.h
src/core/tools/qsize.h
src/test/qbenchmarkmeasurement.cpp

index f450d93..218ba48 100644 (file)
 #  error Unable to detect target endianness
 #endif
 
-// needed for std::round() and std::swap
+// needed for std::swap
 #ifdef __cplusplus
 #include <algorithm>
-#include <cmath>
-#else
-#include <math.h>
 #endif
 
 #if defined(__cplusplus) && !defined(QT_NO_USING_NAMESPACE)
@@ -590,11 +587,6 @@ typedef double qreal;
 template <typename T>
 Q_DECL_CONSTEXPR inline T qAbs(const T &t) { return t >= 0 ? t : -t; }
 
-inline int qRound(qreal d)
-{ return int(std::round(d)); }
-inline qint64 qRound64(qreal d)
-{ return qint64(std::round(d)); }
-
 template <typename T>
 Q_DECL_CONSTEXPR inline const T &qMin(const T &a, const T &b) { return (a < b) ? a : b; }
 template <typename T>
index 0775ee5..61a6656 100644 (file)
@@ -42,7 +42,7 @@
 #ifndef QMATH_H
 #define QMATH_H
 
-#include <math.h>
+#include <cmath>
 
 #include <QtCore/qglobal.h>
 
@@ -56,6 +56,16 @@ QT_BEGIN_NAMESPACE
 
 extern Q_CORE_EXPORT const qreal qt_sine_table[QT_SINE_TABLE_SIZE];
 
+inline int qRound(qreal d)
+{
+    return int(std::round(d));
+}
+
+inline qint64 qRound64(qreal d)
+{
+    return qint64(std::round(d));
+}
+
 inline int qCeil(qreal v)
 {
 #ifdef QT_USE_MATH_H_FLOATS
index 77f02bb..3a9f7c9 100644 (file)
@@ -46,6 +46,7 @@
 #include "qdebug.h"
 #include "qmap.h"
 #include "qdatetime.h"
+#include "qmath.h"
 #ifndef QT_BOOTSTRAPPED
 #include "qeasingcurve.h"
 #endif
index c7fc0ea..91c0956 100644 (file)
 
 #include "qplatformdefs.h"
 #include "qdatetime_p.h"
-
 #include "qdatastream.h"
 #include "qset.h"
 #include "qlocale.h"
 #include "qdatetime.h"
 #include "qregexp.h"
 #include "qdebug.h"
+#include "qmath.h"
 
 #include <time.h>
 
index c9a9510..5299900 100644 (file)
@@ -43,6 +43,7 @@
 #define QPOINT_H
 
 #include <QtCore/qnamespace.h>
+#include <QtCore/qmath.h>
 
 QT_BEGIN_HEADER
 
index d4050ce..77f300b 100644 (file)
@@ -43,6 +43,7 @@
 #define QSIZE_H
 
 #include <QtCore/qnamespace.h>
+#include <QtCore/qmath.h>
 
 QT_BEGIN_HEADER
 
index e38091e..78db678 100644 (file)
@@ -43,7 +43,8 @@
 #include "QtTest/qbenchmark_p.h"
 #include "QtTest/qbenchmarkmetric_p.h"
 #include "qbenchmark.h"
-#include <qdebug.h>
+#include "qmath.h"
+#include "qdebug.h"
 
 QT_BEGIN_NAMESPACE