[poppler] goo/GooCheckedOps.h
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Mon Apr 1 22:38:12 UTC 2019
goo/GooCheckedOps.h | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
New commits:
commit 647344ebbef536248e47b1ab1f1fccb20c941aac
Author: Albert Astals Cid <aacid at kde.org>
Date: Tue Apr 2 00:29:42 2019 +0200
Fix MSVC compile
Windows.h defines max/min macros, these extra parentheses makes it happy
enough ...
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 at t-online.de>
// Copyright (C) 2019 LE GARREC Vincent <legarrec.vincent at gmail.com>
+// Copyright (C) 2019 Albert Astals Cid <aacid at 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);
More information about the poppler
mailing list