Guard against min/max being macros in reader.h
Sometimes, particularly when Microsoft's windows.h is included, min/max are defined as macros, interfering with use of std::numeric_limits::min() and the like. To guard against this, the function name is wrapped in an extra set of parenthesis, which inhibits function-style macro expansion. This is a similar commit to 6e38649ec6, but fixes uses of std::numeric_limits added after that commit, like those introduced in 2ea43433e2.
This commit is contained in:
parent
129d19ba7f
commit
960b9cfd19
@ -1701,7 +1701,7 @@ private:
|
||||
d = internal::StrtodNormalPrecision(d, p);
|
||||
|
||||
// Use > max, instead of == inf, to fix bogus warning -Wfloat-equal
|
||||
if (d > std::numeric_limits<double>::max()) {
|
||||
if (d > (std::numeric_limits<double>::max)()) {
|
||||
// Overflow
|
||||
// TODO: internal::StrtodX should report overflow (or underflow)
|
||||
RAPIDJSON_PARSE_ERROR(kParseErrorNumberTooBig, startOffset);
|
||||
|
@ -79,12 +79,12 @@ static void Verify(void(*f)(T, char*), char* (*g)(T, char*)) {
|
||||
do {
|
||||
VerifyValue<T>(i - 1, f, g);
|
||||
VerifyValue<T>(i, f, g);
|
||||
if (std::numeric_limits<T>::min() < 0) {
|
||||
if ((std::numeric_limits<T>::min)() < 0) {
|
||||
VerifyValue<T>(Traits<T>::Negate(i), f, g);
|
||||
VerifyValue<T>(Traits<T>::Negate(i + 1), f, g);
|
||||
}
|
||||
last = i;
|
||||
if (i > static_cast<T>(std::numeric_limits<T>::max() / static_cast<T>(power)))
|
||||
if (i > static_cast<T>((std::numeric_limits<T>::max)() / static_cast<T>(power)))
|
||||
break;
|
||||
i *= static_cast<T>(power);
|
||||
} while (last < i);
|
||||
|
@ -422,7 +422,7 @@ static void TestParseDouble() {
|
||||
"67546703537516986049910576551282076245490090389328944075868508455133942"
|
||||
"30458323690322294816580855933212334827479782620414472316873817718091929"
|
||||
"9881250404026184124858368",
|
||||
std::numeric_limits<double>::max());
|
||||
(std::numeric_limits<double>::max)());
|
||||
|
||||
TEST_DOUBLE(fullPrecision,
|
||||
"243546080556034731077856379609316893158278902575447060151047"
|
||||
|
Loading…
x
Reference in New Issue
Block a user