Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
R
rapidjson
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
rapidjson
Commits
5db5dd55
Commit
5db5dd55
authored
Sep 06, 2017
by
Milo Yip
Committed by
GitHub
Sep 06, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1057 from chwarr/paren-minmax
Guard against min/max being macros in a cross-compiler way
parents
4bb4926c
e4c0ecf8
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
9 additions
and
23 deletions
+9
-23
document.h
include/rapidjson/document.h
+5
-19
itoatest.cpp
test/unittest/itoatest.cpp
+2
-2
readertest.cpp
test/unittest/readertest.cpp
+1
-1
strtodtest.cpp
test/unittest/strtodtest.cpp
+1
-1
No files found.
include/rapidjson/document.h
View file @
5db5dd55
...
...
@@ -29,14 +29,6 @@ RAPIDJSON_DIAG_PUSH
#ifdef _MSC_VER
RAPIDJSON_DIAG_OFF
(
4127
)
// conditional expression is constant
RAPIDJSON_DIAG_OFF
(
4244
)
// conversion from kXxxFlags to 'uint16_t', possible loss of data
#ifdef _MINWINDEF_ // see: http://stackoverflow.com/questions/22744262/cant-call-stdmax-because-minwindef-h-defines-max
#ifndef NOMINMAX
#pragma push_macro("min")
#pragma push_macro("max")
#undef min
#undef max
#endif
#endif
#endif
#ifdef __clang__
...
...
@@ -1018,14 +1010,14 @@ public:
uint64_t
u
=
GetUint64
();
volatile
double
d
=
static_cast
<
double
>
(
u
);
return
(
d
>=
0
.
0
)
&&
(
d
<
static_cast
<
double
>
(
std
::
numeric_limits
<
uint64_t
>::
max
()))
&&
(
d
<
static_cast
<
double
>
(
(
std
::
numeric_limits
<
uint64_t
>::
max
)
()))
&&
(
u
==
static_cast
<
uint64_t
>
(
d
));
}
if
(
IsInt64
())
{
int64_t
i
=
GetInt64
();
volatile
double
d
=
static_cast
<
double
>
(
i
);
return
(
d
>=
static_cast
<
double
>
(
std
::
numeric_limits
<
int64_t
>::
min
()))
&&
(
d
<
static_cast
<
double
>
(
std
::
numeric_limits
<
int64_t
>::
max
()))
return
(
d
>=
static_cast
<
double
>
(
(
std
::
numeric_limits
<
int64_t
>::
min
)
()))
&&
(
d
<
static_cast
<
double
>
(
(
std
::
numeric_limits
<
int64_t
>::
max
)
()))
&&
(
i
==
static_cast
<
int64_t
>
(
d
));
}
return
true
;
// double, int, uint are always lossless
...
...
@@ -1042,8 +1034,8 @@ public:
bool
IsLosslessFloat
()
const
{
if
(
!
IsNumber
())
return
false
;
double
a
=
GetDouble
();
if
(
a
<
static_cast
<
double
>
(
-
std
::
numeric_limits
<
float
>::
max
())
||
a
>
static_cast
<
double
>
(
std
::
numeric_limits
<
float
>::
max
()))
if
(
a
<
static_cast
<
double
>
(
-
(
std
::
numeric_limits
<
float
>::
max
)
())
||
a
>
static_cast
<
double
>
(
(
std
::
numeric_limits
<
float
>::
max
)
()))
return
false
;
double
b
=
static_cast
<
double
>
(
static_cast
<
float
>
(
a
));
return
a
>=
b
&&
a
<=
b
;
// Prevent -Wfloat-equal
...
...
@@ -2616,12 +2608,6 @@ private:
};
RAPIDJSON_NAMESPACE_END
#ifdef _MINWINDEF_ // see: http://stackoverflow.com/questions/22744262/cant-call-stdmax-because-minwindef-h-defines-max
#ifndef NOMINMAX
#pragma pop_macro("min")
#pragma pop_macro("max")
#endif
#endif
RAPIDJSON_DIAG_POP
#endif // RAPIDJSON_DOCUMENT_H_
test/unittest/itoatest.cpp
View file @
5db5dd55
...
...
@@ -70,8 +70,8 @@ template <typename T>
static
void
Verify
(
void
(
*
f
)(
T
,
char
*
),
char
*
(
*
g
)(
T
,
char
*
))
{
// Boundary cases
VerifyValue
<
T
>
(
0
,
f
,
g
);
VerifyValue
<
T
>
(
std
::
numeric_limits
<
T
>::
min
(),
f
,
g
);
VerifyValue
<
T
>
(
std
::
numeric_limits
<
T
>::
max
(),
f
,
g
);
VerifyValue
<
T
>
(
(
std
::
numeric_limits
<
T
>::
min
)
(),
f
,
g
);
VerifyValue
<
T
>
(
(
std
::
numeric_limits
<
T
>::
max
)
(),
f
,
g
);
// 2^n - 1, 2^n, 10^n - 1, 10^n until overflow
for
(
int
power
=
2
;
power
<=
10
;
power
+=
8
)
{
...
...
test/unittest/readertest.cpp
View file @
5db5dd55
...
...
@@ -415,7 +415,7 @@ TEST(Reader, ParseNumber_NormalPrecisionError) {
uint64_t
bias1
=
e
.
ToBias
();
uint64_t
bias2
=
a
.
ToBias
();
double
ulp
=
static_cast
<
double
>
(
bias1
>=
bias2
?
bias1
-
bias2
:
bias2
-
bias1
);
ulpMax
=
std
::
max
(
ulpMax
,
ulp
);
ulpMax
=
(
std
::
max
)
(
ulpMax
,
ulp
);
ulpSum
+=
ulp
;
}
printf
(
"ULP Average = %g, Max = %g
\n
"
,
ulpSum
/
count
,
ulpMax
);
...
...
test/unittest/strtodtest.cpp
View file @
5db5dd55
...
...
@@ -91,7 +91,7 @@ TEST(Strtod, CheckApproximationCase) {
}
// Remove common power of two factor from all three scaled values
int
common_Exp2
=
std
::
min
(
dS_Exp2
,
std
::
min
(
bS_Exp2
,
hS_Exp2
));
int
common_Exp2
=
(
std
::
min
)(
dS_Exp2
,
(
std
::
min
)
(
bS_Exp2
,
hS_Exp2
));
dS_Exp2
-=
common_Exp2
;
bS_Exp2
-=
common_Exp2
;
hS_Exp2
-=
common_Exp2
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment