Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
json
Project
Overview
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
json
Commits
d62d48fc
Unverified
Commit
d62d48fc
authored
Apr 07, 2017
by
Niels Lohmann
Browse files
Options
Browse Files
Download
Plain Diff
🔀
merge branch 'develop' into feature/manual_lexer
parents
ff72f388
90273e93
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
123 additions
and
0 deletions
+123
-0
json.hpp
src/json.hpp
+88
-0
unit-regression.cpp
test/src/unit-regression.cpp
+35
-0
No files found.
src/json.hpp
View file @
d62d48fc
...
@@ -6396,6 +6396,28 @@ class basic_json
...
@@ -6396,6 +6396,28 @@ class basic_json
}
}
/*!
/*!
@brief comparison: less than
@copydoc operator<(const_reference, const_reference)
*/
template
<
typename
ScalarType
,
typename
std
::
enable_if
<
std
::
is_scalar
<
ScalarType
>::
value
,
int
>::
type
=
0
>
friend
bool
operator
<
(
const_reference
lhs
,
const
ScalarType
rhs
)
noexcept
{
return
(
lhs
<
basic_json
(
rhs
));
}
/*!
@brief comparison: less than
@copydoc operator<(const_reference, const_reference)
*/
template
<
typename
ScalarType
,
typename
std
::
enable_if
<
std
::
is_scalar
<
ScalarType
>::
value
,
int
>::
type
=
0
>
friend
bool
operator
<
(
const
ScalarType
lhs
,
const_reference
rhs
)
noexcept
{
return
(
basic_json
(
lhs
)
<
rhs
);
}
/*!
@brief comparison: less than or equal
@brief comparison: less than or equal
Compares whether one JSON value @a lhs is less than or equal to another
Compares whether one JSON value @a lhs is less than or equal to another
...
@@ -6418,6 +6440,28 @@ class basic_json
...
@@ -6418,6 +6440,28 @@ class basic_json
}
}
/*!
/*!
@brief comparison: less than or equal
@copydoc operator<=(const_reference, const_reference)
*/
template
<
typename
ScalarType
,
typename
std
::
enable_if
<
std
::
is_scalar
<
ScalarType
>::
value
,
int
>::
type
=
0
>
friend
bool
operator
<=
(
const_reference
lhs
,
const
ScalarType
rhs
)
noexcept
{
return
(
lhs
<=
basic_json
(
rhs
));
}
/*!
@brief comparison: less than or equal
@copydoc operator<=(const_reference, const_reference)
*/
template
<
typename
ScalarType
,
typename
std
::
enable_if
<
std
::
is_scalar
<
ScalarType
>::
value
,
int
>::
type
=
0
>
friend
bool
operator
<=
(
const
ScalarType
lhs
,
const_reference
rhs
)
noexcept
{
return
(
basic_json
(
lhs
)
<=
rhs
);
}
/*!
@brief comparison: greater than
@brief comparison: greater than
Compares whether one JSON value @a lhs is greater than another
Compares whether one JSON value @a lhs is greater than another
...
@@ -6440,6 +6484,28 @@ class basic_json
...
@@ -6440,6 +6484,28 @@ class basic_json
}
}
/*!
/*!
@brief comparison: greater than
@copydoc operator>(const_reference, const_reference)
*/
template
<
typename
ScalarType
,
typename
std
::
enable_if
<
std
::
is_scalar
<
ScalarType
>::
value
,
int
>::
type
=
0
>
friend
bool
operator
>
(
const_reference
lhs
,
const
ScalarType
rhs
)
noexcept
{
return
(
lhs
>
basic_json
(
rhs
));
}
/*!
@brief comparison: greater than
@copydoc operator>(const_reference, const_reference)
*/
template
<
typename
ScalarType
,
typename
std
::
enable_if
<
std
::
is_scalar
<
ScalarType
>::
value
,
int
>::
type
=
0
>
friend
bool
operator
>
(
const
ScalarType
lhs
,
const_reference
rhs
)
noexcept
{
return
(
basic_json
(
lhs
)
>
rhs
);
}
/*!
@brief comparison: greater than or equal
@brief comparison: greater than or equal
Compares whether one JSON value @a lhs is greater than or equal to another
Compares whether one JSON value @a lhs is greater than or equal to another
...
@@ -6461,6 +6527,28 @@ class basic_json
...
@@ -6461,6 +6527,28 @@ class basic_json
return
not
(
lhs
<
rhs
);
return
not
(
lhs
<
rhs
);
}
}
/*!
@brief comparison: greater than or equal
@copydoc operator>=(const_reference, const_reference)
*/
template
<
typename
ScalarType
,
typename
std
::
enable_if
<
std
::
is_scalar
<
ScalarType
>::
value
,
int
>::
type
=
0
>
friend
bool
operator
>=
(
const_reference
lhs
,
const
ScalarType
rhs
)
noexcept
{
return
(
lhs
>=
basic_json
(
rhs
));
}
/*!
@brief comparison: greater than or equal
@copydoc operator>=(const_reference, const_reference)
*/
template
<
typename
ScalarType
,
typename
std
::
enable_if
<
std
::
is_scalar
<
ScalarType
>::
value
,
int
>::
type
=
0
>
friend
bool
operator
>=
(
const
ScalarType
lhs
,
const_reference
rhs
)
noexcept
{
return
(
basic_json
(
lhs
)
>=
rhs
);
}
/// @}
/// @}
...
...
test/src/unit-regression.cpp
View file @
d62d48fc
...
@@ -975,4 +975,39 @@ TEST_CASE("regression tests")
...
@@ -975,4 +975,39 @@ TEST_CASE("regression tests")
// check if serializations match
// check if serializations match
CHECK
(
json
::
to_cbor
(
j2
)
==
vec2
);
CHECK
(
json
::
to_cbor
(
j2
)
==
vec2
);
}
}
SECTION
(
"issue #512 - use of overloaded operator '<=' is ambiguous"
)
{
json
j
;
j
[
"a"
]
=
5
;
// json op scalar
CHECK
(
j
[
"a"
]
==
5
);
CHECK
(
j
[
"a"
]
!=
4
);
CHECK
(
j
[
"a"
]
<=
7
);
CHECK
(
j
[
"a"
]
<
7
);
CHECK
(
j
[
"a"
]
>=
3
);
CHECK
(
j
[
"a"
]
>
3
);
CHECK
(
not
(
j
[
"a"
]
<=
4
));
CHECK
(
not
(
j
[
"a"
]
<
4
));
CHECK
(
not
(
j
[
"a"
]
>=
6
));
CHECK
(
not
(
j
[
"a"
]
>
6
));
// scalar op json
CHECK
(
5
==
j
[
"a"
]);
CHECK
(
4
!=
j
[
"a"
]);
CHECK
(
7
>=
j
[
"a"
]);
CHECK
(
7
>
j
[
"a"
]);
CHECK
(
3
<=
j
[
"a"
]);
CHECK
(
3
<
j
[
"a"
]);
CHECK
(
not
(
4
>=
j
[
"a"
]));
CHECK
(
not
(
4
>
j
[
"a"
]));
CHECK
(
not
(
6
<=
j
[
"a"
]));
CHECK
(
not
(
6
<
j
[
"a"
]));
}
}
}
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