summaryrefslogtreecommitdiff
path: root/goo
diff options
context:
space:
mode:
authorAlbert Astals Cid <aacid@kde.org>2019-04-02 00:29:42 +0200
committerAlbert Astals Cid <aacid@kde.org>2019-04-02 00:29:42 +0200
commit647344ebbef536248e47b1ab1f1fccb20c941aac (patch)
tree25d1177411a59e88099e7d93184d7551a9d6d07a /goo
parenta17bfb24f7caa4ab5cd7ecc0ccbb7cfc7d72c62a (diff)
Fix MSVC compile
Windows.h defines max/min macros, these extra parentheses makes it happy enough ...
Diffstat (limited to 'goo')
-rw-r--r--goo/GooCheckedOps.h13
1 files changed, 7 insertions, 6 deletions
diff --git a/goo/GooCheckedOps.h b/goo/GooCheckedOps.h
index c49a621f..96c2f517 100644
--- a/goo/GooCheckedOps.h
+++ b/goo/GooCheckedOps.h
@@ -6,6 +6,7 @@
//
// Copyright (C) 2018 Adam Reichold <adam.reichold@t-online.de>
// Copyright (C) 2019 LE GARREC Vincent <legarrec.vincent@gmail.com>
+// Copyright (C) 2019 Albert Astals Cid <aacid@kde.org>
//
//========================================================================
@@ -16,13 +17,13 @@
#include <type_traits>
template<typename T> inline bool checkedAssign(long long lz, T *z) {
- static_assert(std::numeric_limits<long long>::max() > std::numeric_limits<T>::max(),
+ static_assert((std::numeric_limits<long long>::max)() > (std::numeric_limits<T>::max)(),
"The max of long long type must be larger to perform overflow checks.");
- static_assert(std::numeric_limits<long long>::min() < std::numeric_limits<T>::min(),
+ static_assert((std::numeric_limits<long long>::min)() < (std::numeric_limits<T>::min)(),
"The min of long long type must be smaller to perform overflow checks.");
- if (lz > std::numeric_limits<T>::max() ||
- lz < std::numeric_limits<T>::min()) {
+ if (lz > (std::numeric_limits<T>::max)() ||
+ lz < (std::numeric_limits<T>::min)()) {
return true;
}
@@ -53,9 +54,9 @@ template<typename T> inline bool checkedMultiply(T x, T y, T *z) {
}
template<typename T> inline T safeAverage(T a, T b) {
- static_assert(std::numeric_limits<long long>::max() > std::numeric_limits<T>::max(),
+ static_assert((std::numeric_limits<long long>::max)() > (std::numeric_limits<T>::max)(),
"The max of long long type must be larger to perform overflow checks.");
- static_assert(std::numeric_limits<long long>::min() < std::numeric_limits<T>::min(),
+ static_assert((std::numeric_limits<long long>::min)() < (std::numeric_limits<T>::min)(),
"The min of long long type must be smaller to perform overflow checks.");
return static_cast<T>((static_cast<long long>(a) + static_cast<long long>(b)) / 2);