diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2017-12-21 10:38:19 -0200 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2017-12-28 21:30:28 +0000 |
commit | 656804b9645a83430dcd0929c49b4065d43d7990 (patch) | |
tree | 42dbf3803057dfced51440d9f0976a0f6f497e6a /src/corelib/global/qrandom.h | |
parent | 0fd5fe28abd557f96b78c5b52b21efe50ec6763b (diff) |
qrandom.h: actually #undef min and max instead of using parentheses
Putting parentheses around the call to (std::numeric_limits<T>::min)()
works, but the trick cannot apply to the min() function declaration on
the same line. So we really need to #undef.
I hope no one after the 1990s still needs these macros.
Task-number: QTBUG-65414
Change-Id: I39332e0a867442d58082fffd15024f8edb293311
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Diffstat (limited to 'src/corelib/global/qrandom.h')
-rw-r--r-- | src/corelib/global/qrandom.h | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/corelib/global/qrandom.h b/src/corelib/global/qrandom.h index cbeab19a7b..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 @@ -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(); @@ -236,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(); |