From 656804b9645a83430dcd0929c49b4065d43d7990 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 21 Dec 2017 10:38:19 -0200 Subject: [PATCH] qrandom.h: actually #undef min and max instead of using parentheses Putting parentheses around the call to (std::numeric_limits::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 Reviewed-by: Lars Knoll Reviewed-by: Timur Pocheptsov --- src/corelib/global/qrandom.h | 15 +++++++++++---- 1 file 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 // for std::generate #include // 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::min)(); } - static Q_DECL_CONSTEXPR result_type max() { return (std::numeric_limits::max)(); } + static Q_DECL_CONSTEXPR result_type min() { return std::numeric_limits::min(); } + static Q_DECL_CONSTEXPR result_type max() { return std::numeric_limits::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::min)(); } - static Q_DECL_CONSTEXPR result_type max() { return (std::numeric_limits::max)(); } + static Q_DECL_CONSTEXPR result_type min() { return std::numeric_limits::min(); } + static Q_DECL_CONSTEXPR result_type max() { return std::numeric_limits::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();