Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
json
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
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
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
123 additions
and
0 deletions
+123
-0
src/json.hpp
src/json.hpp
+88
-0
test/src/unit-regression.cpp
test/src/unit-regression.cpp
+35
-0
No files found.
src/json.hpp
View file @
d62d48fc
...
@@ -6395,6 +6395,28 @@ class basic_json
...
@@ -6395,6 +6395,28 @@ class basic_json
return
operator
<
(
lhs_type
,
rhs_type
);
return
operator
<
(
lhs_type
,
rhs_type
);
}
}
/*!
@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
...
@@ -6417,6 +6439,28 @@ class basic_json
...
@@ -6417,6 +6439,28 @@ class basic_json
return
not
(
rhs
<
lhs
);
return
not
(
rhs
<
lhs
);
}
}
/*!
@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
...
@@ -6439,6 +6483,28 @@ class basic_json
...
@@ -6439,6 +6483,28 @@ class basic_json
return
not
(
lhs
<=
rhs
);
return
not
(
lhs
<=
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_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
...
@@ -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