summaryrefslogtreecommitdiffstats
path: root/src/corelib/global/qrandom.h
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2017-12-30 17:39:21 +0100
committerLars Knoll <lars.knoll@qt.io>2018-01-02 09:58:44 +0100
commit0f315adf9199efcfafa44371464ab6d1fc866774 (patch)
tree35b67591255624c670aff0579e45b2973f56fd81 /src/corelib/global/qrandom.h
parent2b0eb3fac319a17dd92903106d501f0f06df871f (diff)
parent52b85212a2ec8ec5bf187f6cd00b669a45bcf0bd (diff)
Merge remote-tracking branch 'origin/5.10' into dev
Conflicts: .qmake.conf sc/corelib/io/qfsfileengine_p.h src/corelib/io/qstorageinfo_unix.cpp src/platformsupport/eglconvenience/qeglpbuffer_p.h src/platformsupport/input/libinput/qlibinputkeyboard.cpp src/platformsupport/input/libinput/qlibinputpointer.cpp src/plugins/platforms/cocoa/qcocoamenu.mm src/plugins/platforms/ios/qiosscreen.h src/plugins/platforms/ios/qioswindow.h src/plugins/platforms/ios/quiview.mm src/printsupport/dialogs/qpagesetupdialog_unix_p.h src/printsupport/dialogs/qprintpreviewdialog.cpp src/printsupport/widgets/qcupsjobwidget_p.h src/widgets/widgets/qmenu.cpp tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp Change-Id: Iecb4883122efe97ef0ed850271e6c51bab568e9c
Diffstat (limited to 'src/corelib/global/qrandom.h')
-rw-r--r--src/corelib/global/qrandom.h28
1 files changed, 18 insertions, 10 deletions
diff --git a/src/corelib/global/qrandom.h b/src/corelib/global/qrandom.h
index bde64646a4..46d3e0e152 100644
--- a/src/corelib/global/qrandom.h
+++ b/src/corelib/global/qrandom.h
@@ -44,6 +44,13 @@
#include <algorithm> // for std::generate
#include <random> // for std::mt19937
+#ifdef min
+# undef min
+#endif
+#ifdef max
+# undef max
+#endif
+
QT_BEGIN_NAMESPACE
class QRandomGenerator
@@ -55,10 +62,10 @@ public:
QRandomGenerator(quint32 seedValue = 1)
: QRandomGenerator(&seedValue, 1)
{}
- template <qssize_t N> QRandomGenerator(const quint32 (&seedBuffer)[N])
+ template <qsizetype N> QRandomGenerator(const quint32 (&seedBuffer)[N])
: QRandomGenerator(seedBuffer, seedBuffer + N)
{}
- QRandomGenerator(const quint32 *seedBuffer, qssize_t len)
+ QRandomGenerator(const quint32 *seedBuffer, qsizetype len)
: QRandomGenerator(seedBuffer, seedBuffer + len)
{}
Q_CORE_EXPORT QRandomGenerator(std::seed_seq &sseq) Q_DECL_NOTHROW;
@@ -131,7 +138,7 @@ public:
}
template <typename UInt, IfValidUInt<UInt> = true>
- void fillRange(UInt *buffer, qssize_t count)
+ void fillRange(UInt *buffer, qsizetype count)
{
_fillRange(buffer, buffer + count);
}
@@ -160,8 +167,8 @@ public:
void seed(quint32 s = 1) { *this = { s }; }
void seed(std::seed_seq &sseq) Q_DECL_NOTHROW { *this = { sseq }; }
Q_CORE_EXPORT void discard(unsigned long long z);
- static Q_DECL_CONSTEXPR result_type min() { return (std::numeric_limits<result_type>::min)(); }
- static Q_DECL_CONSTEXPR result_type max() { return (std::numeric_limits<result_type>::max)(); }
+ static Q_DECL_CONSTEXPR result_type min() { return std::numeric_limits<result_type>::min(); }
+ static Q_DECL_CONSTEXPR result_type max() { return std::numeric_limits<result_type>::max(); }
static inline Q_DECL_CONST_FUNCTION QRandomGenerator *system();
static inline Q_DECL_CONST_FUNCTION QRandomGenerator *global();
@@ -177,7 +184,8 @@ private:
friend class QRandomGenerator64;
struct SystemGenerator;
struct SystemAndGlobalGenerators;
- typedef std::mt19937 RandomEngine;
+ using RandomEngine = std::mersenne_twister_engine<quint32,
+ 32,624,397,31,0x9908b0df,11,0xffffffff,7,0x9d2c5680,15,0xefc60000,18,1812433253>;
union Storage {
uint dummy;
@@ -214,10 +222,10 @@ public:
QRandomGenerator64(quint32 seedValue = 1)
: QRandomGenerator(seedValue)
{}
- template <qssize_t N> QRandomGenerator64(const quint32 (&seedBuffer)[N])
+ template <qsizetype N> QRandomGenerator64(const quint32 (&seedBuffer)[N])
: QRandomGenerator(seedBuffer)
{}
- QRandomGenerator64(const quint32 *seedBuffer, qssize_t len)
+ QRandomGenerator64(const quint32 *seedBuffer, qsizetype len)
: QRandomGenerator(seedBuffer, len)
{}
QRandomGenerator64(std::seed_seq &sseq) Q_DECL_NOTHROW
@@ -235,8 +243,8 @@ public:
QRandomGenerator::discard(z * 2);
}
- static Q_DECL_CONSTEXPR result_type min() { return (std::numeric_limits<result_type>::min)(); }
- static Q_DECL_CONSTEXPR result_type max() { return (std::numeric_limits<result_type>::max)(); }
+ static Q_DECL_CONSTEXPR result_type min() { return std::numeric_limits<result_type>::min(); }
+ static Q_DECL_CONSTEXPR result_type max() { return std::numeric_limits<result_type>::max(); }
static Q_DECL_CONST_FUNCTION Q_CORE_EXPORT QRandomGenerator64 *system();
static Q_DECL_CONST_FUNCTION Q_CORE_EXPORT QRandomGenerator64 *global();
static Q_CORE_EXPORT QRandomGenerator64 securelySeeded();