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
1566ad40
Commit
1566ad40
authored
7 years ago
by
Danielc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed compile error for #1045; to_json for iternation_proxy_internal was needed
parent
8d8f8907
develop
bon8
coverity_scan
feature/optional
gcc_warning_flags
icpc
issue2228
issue2615
issue2932
issue3232_use_catch
master
release/3.10.2
release/3.10.3
release/3.10.4
release/3.10.5
string_view
string_view2
update_doctest
3.6.1
3.3.0
3.2.0
v3.10.5
v3.10.4
v3.10.3
v3.10.2
v3.10.1
v3.10.0
v3.9.1
v3.9.0
v3.8.0
v3.7.3
v3.7.2
v3.7.1
v3.7.0
v3.6.1
v3.6.0
v3.5.0
v3.4.0
v3.3.0
v3.2.0
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
5 deletions
+29
-5
include/nlohmann/detail/conversions/to_json.hpp
include/nlohmann/detail/conversions/to_json.hpp
+10
-0
single_include/nlohmann/json.hpp
single_include/nlohmann/json.hpp
+16
-3
test/src/unit-regression.cpp
test/src/unit-regression.cpp
+3
-2
No files found.
include/nlohmann/detail/conversions/to_json.hpp
View file @
1566ad40
...
...
@@ -284,6 +284,16 @@ void to_json(BasicJsonType& j, const std::pair<Args...>& p)
j
=
{
p
.
first
,
p
.
second
};
}
template
<
typename
IteratorType
>
class
iteration_proxy
;
// TODO: Forward decl needed, maybe move somewhere else
template
<
typename
BasicJsonType
,
typename
T
,
enable_if_t
<
std
::
is_same
<
T
,
typename
iteration_proxy
<
typename
BasicJsonType
::
iterator
>
::
iteration_proxy_internal
>::
value
,
int
>
=
0
>
void
to_json
(
BasicJsonType
&
j
,
T
b
)
noexcept
{
typename
BasicJsonType
::
object_t
tmp_obj
;
tmp_obj
[
b
.
key
()]
=
b
.
value
();
// TODO: maybe there is a better way?
external_constructor
<
value_t
::
object
>::
construct
(
j
,
std
::
move
(
tmp_obj
));
}
template
<
typename
BasicJsonType
,
typename
Tuple
,
std
::
size_t
...
Idx
>
void
to_json_tuple_impl
(
BasicJsonType
&
j
,
const
Tuple
&
t
,
index_sequence
<
Idx
...
>
)
{
...
...
This diff is collapsed.
Click to expand it.
single_include/nlohmann/json.hpp
View file @
1566ad40
...
...
@@ -1516,6 +1516,16 @@ void to_json(BasicJsonType& j, const std::pair<Args...>& p)
j
=
{
p
.
first
,
p
.
second
};
}
template
<
typename
IteratorType
>
class
iteration_proxy
;
// TODO: Forward decl needed, maybe move somewhere else
template
<
typename
BasicJsonType
,
typename
T
,
enable_if_t
<
std
::
is_same
<
T
,
typename
iteration_proxy
<
typename
BasicJsonType
::
iterator
>
::
iteration_proxy_internal
>::
value
,
int
>
=
0
>
void
to_json
(
BasicJsonType
&
j
,
T
b
)
noexcept
{
typename
BasicJsonType
::
object_t
tmp_obj
;
tmp_obj
[
b
.
key
()]
=
b
.
value
();
// TODO: maybe there is a better way?
external_constructor
<
value_t
::
object
>::
construct
(
j
,
std
::
move
(
tmp_obj
));
}
template
<
typename
BasicJsonType
,
typename
Tuple
,
std
::
size_t
...
Idx
>
void
to_json_tuple_impl
(
BasicJsonType
&
j
,
const
Tuple
&
t
,
index_sequence
<
Idx
...
>
)
{
...
...
@@ -7393,7 +7403,7 @@ boundaries compute_boundaries(FloatType value)
constexpr
int
kMinExp
=
1
-
kBias
;
constexpr
uint64_t
kHiddenBit
=
uint64_t
{
1
}
<<
(
kPrecision
-
1
);
// = 2^(p-1)
using
bits_type
=
typename
std
::
conditional
<
kPrecision
==
24
,
uint32_t
,
uint64_t
>::
type
;
using
bits_type
=
typename
std
::
conditional
<
kPrecision
==
24
,
uint32_t
,
uint64_t
>::
type
;
const
uint64_t
bits
=
reinterpret_bits
<
bits_type
>
(
value
);
const
uint64_t
E
=
bits
>>
(
kPrecision
-
1
);
...
...
@@ -7804,7 +7814,10 @@ inline void grisu2_digit_gen(char* buffer, int& length, int& decimal_exponent,
// = ((p1 ) * 2^-e + (p2 )) * 2^e
// = p1 + p2 * 2^e
const
diyfp
one
(
uint64_t
{
1
}
<<
-
M_plus
.
e
,
M_plus
.
e
);
const
diyfp
one
(
uint64_t
{
1
}
<<
-
M_plus
.
e
,
M_plus
.
e
);
uint32_t
p1
=
static_cast
<
uint32_t
>
(
M_plus
.
f
>>
-
one
.
e
);
// p1 = f div 2^-e (Since -e >= 32, p1 fits into a 32-bit int.)
uint64_t
p2
=
M_plus
.
f
&
(
one
.
f
-
1
);
// p2 = f mod 2^-e
...
...
@@ -17268,7 +17281,7 @@ struct hash<nlohmann::json>
/// @note: do not remove the space after '<',
/// see https://github.com/nlohmann/json/pull/679
template
<
>
struct
less
<
::
nlohmann
::
detail
::
value_t
>
struct
less
<::
nlohmann
::
detail
::
value_t
>
{
/*!
@brief compare two value_t enum values
...
...
This diff is collapsed.
Click to expand it.
test/src/unit-regression.cpp
View file @
1566ad40
...
...
@@ -1631,9 +1631,10 @@ TEST_CASE("regression tests")
p2
.
begin
(),
p2
.
end
(),
std
::
inserter
(
diffs
,
diffs
.
end
()),
[
&
](
const
it_type
&
e1
,
const
it_type
&
e2
)
->
bool
{
return
(
e1
.
key
()
<
e2
.
key
())
and
(
e1
.
value
()
<
e2
.
value
());
using
comper_pair
=
std
::
pair
<
std
::
string
,
decltype
(
e1
.
value
())
>
;
// Trying to avoid unneeded copy
return
comper_pair
(
e1
.
key
(),
e1
.
value
())
<
comper_pair
(
e2
.
key
(),
e2
.
value
());
// Using pair comper
});
CHECK
(
diffs
.
size
()
==
2
);
CHECK
(
diffs
.
size
()
==
1
);
// Note the change here, was 2
}
}
This diff is collapsed.
Click to expand it.
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