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
d7c0f157
Commit
d7c0f157
authored
Jan 13, 2021
by
Anthony VH
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merged from_json for pair and tuple to try to fix C2995 error in old MSVC versions.
parent
fbf6df63
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
56 deletions
+42
-56
from_json.hpp
include/nlohmann/detail/conversions/from_json.hpp
+21
-28
json.hpp
single_include/nlohmann/json.hpp
+21
-28
No files found.
include/nlohmann/detail/conversions/from_json.hpp
View file @
d7c0f157
...
...
@@ -188,7 +188,10 @@ auto from_json_array_impl(const BasicJsonType& j, std::array<T, N>& arr,
}
}
template
<
typename
BasicJsonType
,
typename
ConstructibleArrayType
>
template
<
typename
BasicJsonType
,
typename
ConstructibleArrayType
,
enable_if_t
<
std
::
is_assignable
<
ConstructibleArrayType
&
,
ConstructibleArrayType
>::
value
,
int
>
=
0
>
auto
from_json_array_impl
(
const
BasicJsonType
&
j
,
ConstructibleArrayType
&
arr
,
priority_tag
<
1
>
/*unused*/
)
->
decltype
(
arr
.
reserve
(
std
::
declval
<
typename
ConstructibleArrayType
::
size_type
>
()),
...
...
@@ -209,7 +212,10 @@ auto from_json_array_impl(const BasicJsonType& j, ConstructibleArrayType& arr, p
arr
=
std
::
move
(
ret
);
}
template
<
typename
BasicJsonType
,
typename
ConstructibleArrayType
>
template
<
typename
BasicJsonType
,
typename
ConstructibleArrayType
,
enable_if_t
<
std
::
is_assignable
<
ConstructibleArrayType
&
,
ConstructibleArrayType
>::
value
,
int
>
=
0
>
void
from_json_array_impl
(
const
BasicJsonType
&
j
,
ConstructibleArrayType
&
arr
,
priority_tag
<
0
>
/*unused*/
)
{
...
...
@@ -344,53 +350,40 @@ void from_json(const BasicJsonType& j, ArithmeticType& val)
}
}
template
<
typename
BasicJsonType
,
typename
...
Args
,
std
::
size_t
...
Idx
>
std
::
tuple
<
Args
...
>
from_json_tuple_impl_base
(
BasicJsonType
&&
j
,
index_sequence
<
Idx
...
>
/*unused*/
)
{
return
std
::
make_tuple
(
std
::
forward
<
BasicJsonType
>
(
j
).
at
(
Idx
).
template
get
<
Args
>
()...);
}
template
<
typename
BasicJsonType
,
class
A1
,
class
A2
>
std
::
pair
<
A1
,
A2
>
from_json_
pair
_impl
(
BasicJsonType
&&
j
,
identity_tag
<
std
::
pair
<
A1
,
A2
>>
/*unused*/
,
priority_tag
<
0
>
/*unused*/
)
std
::
pair
<
A1
,
A2
>
from_json_
tuple
_impl
(
BasicJsonType
&&
j
,
identity_tag
<
std
::
pair
<
A1
,
A2
>>
/*unused*/
,
priority_tag
<
0
>
/*unused*/
)
{
return
{
std
::
forward
<
BasicJsonType
>
(
j
).
at
(
0
).
template
get
<
A1
>
(),
std
::
forward
<
BasicJsonType
>
(
j
).
at
(
1
).
template
get
<
A2
>
()};
}
template
<
typename
BasicJsonType
,
typename
A1
,
typename
A2
>
void
from_json_
pair
_impl
(
BasicJsonType
&&
j
,
std
::
pair
<
A1
,
A2
>&
p
,
priority_tag
<
1
>
/*unused*/
)
void
from_json_
tuple
_impl
(
BasicJsonType
&&
j
,
std
::
pair
<
A1
,
A2
>&
p
,
priority_tag
<
1
>
/*unused*/
)
{
p
=
from_json_pair_impl
(
std
::
forward
<
BasicJsonType
>
(
j
),
identity_tag
<
std
::
pair
<
A1
,
A2
>>
{},
priority_tag
<
0
>
{});
}
template
<
typename
BasicJsonType
,
typename
PairRelatedType
>
auto
from_json
(
BasicJsonType
&&
j
,
PairRelatedType
&&
p
)
->
decltype
(
from_json_pair_impl
(
std
::
forward
<
BasicJsonType
>
(
j
),
std
::
forward
<
PairRelatedType
>
(
p
),
priority_tag
<
1
>
{}))
{
if
(
JSON_HEDLEY_UNLIKELY
(
!
j
.
is_array
()))
{
JSON_THROW
(
type_error
::
create
(
302
,
"type must be array, but is "
+
std
::
string
(
j
.
type_name
())));
}
return
from_json_pair_impl
(
std
::
forward
<
BasicJsonType
>
(
j
),
std
::
forward
<
PairRelatedType
>
(
p
),
priority_tag
<
1
>
{});
}
template
<
typename
BasicJsonType
,
typename
...
Args
,
std
::
size_t
...
Idx
>
std
::
tuple
<
Args
...
>
from_json_tuple_impl_base
(
BasicJsonType
&&
j
,
index_sequence
<
Idx
...
>
/*unused*/
)
{
return
std
::
make_tuple
(
std
::
forward
<
BasicJsonType
>
(
j
).
at
(
Idx
).
template
get
<
Args
>
()...);
p
=
from_json_tuple_impl
(
std
::
forward
<
BasicJsonType
>
(
j
),
identity_tag
<
std
::
pair
<
A1
,
A2
>>
{},
priority_tag
<
0
>
{});
}
template
<
typename
BasicJsonType
,
typename
...
Args
>
std
::
tuple
<
Args
...
>
from_json_tuple_impl
(
BasicJsonType
&&
j
,
identity_tag
<
std
::
tuple
<
Args
...
>>
/*unused*/
,
priority_tag
<
0
>
/*unused*/
)
std
::
tuple
<
Args
...
>
from_json_tuple_impl
(
BasicJsonType
&&
j
,
identity_tag
<
std
::
tuple
<
Args
...
>>
/*unused*/
,
priority_tag
<
2
>
/*unused*/
)
{
return
from_json_tuple_impl_base
<
BasicJsonType
,
Args
...
>
(
std
::
forward
<
BasicJsonType
>
(
j
),
index_sequence_for
<
Args
...
>
{});
}
template
<
typename
BasicJsonType
,
typename
...
Args
>
void
from_json_tuple_impl
(
BasicJsonType
&&
j
,
std
::
tuple
<
Args
...
>&
t
,
priority_tag
<
1
>
/*unused*/
)
void
from_json_tuple_impl
(
BasicJsonType
&&
j
,
std
::
tuple
<
Args
...
>&
t
,
priority_tag
<
3
>
/*unused*/
)
{
t
=
from_json_tuple_impl_base
<
BasicJsonType
,
Args
...
>
(
std
::
forward
<
BasicJsonType
>
(
j
),
index_sequence_for
<
Args
...
>
{});
}
template
<
typename
BasicJsonType
,
typename
TupleRelated
>
auto
from_json
(
BasicJsonType
&&
j
,
TupleRelated
&&
t
)
->
decltype
(
from_json_tuple_impl
(
std
::
forward
<
BasicJsonType
>
(
j
),
std
::
forward
<
TupleRelated
>
(
t
),
priority_tag
<
1
>
{}))
->
decltype
(
from_json_tuple_impl
(
std
::
forward
<
BasicJsonType
>
(
j
),
std
::
forward
<
TupleRelated
>
(
t
),
priority_tag
<
3
>
{}))
{
if
(
JSON_HEDLEY_UNLIKELY
(
!
j
.
is_array
()))
{
...
...
@@ -398,7 +391,7 @@ auto from_json(BasicJsonType&& j, TupleRelated&& t)
std
::
string
(
j
.
type_name
())));
}
return
from_json_tuple_impl
(
std
::
forward
<
BasicJsonType
>
(
j
),
std
::
forward
<
TupleRelated
>
(
t
),
priority_tag
<
1
>
{});
return
from_json_tuple_impl
(
std
::
forward
<
BasicJsonType
>
(
j
),
std
::
forward
<
TupleRelated
>
(
t
),
priority_tag
<
3
>
{});
}
template
<
typename
BasicJsonType
,
typename
Key
,
typename
Value
,
typename
Compare
,
typename
Allocator
,
...
...
single_include/nlohmann/json.hpp
View file @
d7c0f157
...
...
@@ -3724,7 +3724,10 @@ auto from_json_array_impl(const BasicJsonType& j, std::array<T, N>& arr,
}
}
template
<
typename
BasicJsonType
,
typename
ConstructibleArrayType
>
template
<
typename
BasicJsonType
,
typename
ConstructibleArrayType
,
enable_if_t
<
std
::
is_assignable
<
ConstructibleArrayType
&
,
ConstructibleArrayType
>::
value
,
int
>
=
0
>
auto
from_json_array_impl
(
const
BasicJsonType
&
j
,
ConstructibleArrayType
&
arr
,
priority_tag
<
1
>
/*unused*/
)
->
decltype
(
arr
.
reserve
(
std
::
declval
<
typename
ConstructibleArrayType
::
size_type
>
()),
...
...
@@ -3745,7 +3748,10 @@ auto from_json_array_impl(const BasicJsonType& j, ConstructibleArrayType& arr, p
arr
=
std
::
move
(
ret
);
}
template
<
typename
BasicJsonType
,
typename
ConstructibleArrayType
>
template
<
typename
BasicJsonType
,
typename
ConstructibleArrayType
,
enable_if_t
<
std
::
is_assignable
<
ConstructibleArrayType
&
,
ConstructibleArrayType
>::
value
,
int
>
=
0
>
void
from_json_array_impl
(
const
BasicJsonType
&
j
,
ConstructibleArrayType
&
arr
,
priority_tag
<
0
>
/*unused*/
)
{
...
...
@@ -3880,53 +3886,40 @@ void from_json(const BasicJsonType& j, ArithmeticType& val)
}
}
template
<
typename
BasicJsonType
,
typename
...
Args
,
std
::
size_t
...
Idx
>
std
::
tuple
<
Args
...
>
from_json_tuple_impl_base
(
BasicJsonType
&&
j
,
index_sequence
<
Idx
...
>
/*unused*/
)
{
return
std
::
make_tuple
(
std
::
forward
<
BasicJsonType
>
(
j
).
at
(
Idx
).
template
get
<
Args
>
()...);
}
template
<
typename
BasicJsonType
,
class
A1
,
class
A2
>
std
::
pair
<
A1
,
A2
>
from_json_
pair
_impl
(
BasicJsonType
&&
j
,
identity_tag
<
std
::
pair
<
A1
,
A2
>>
/*unused*/
,
priority_tag
<
0
>
/*unused*/
)
std
::
pair
<
A1
,
A2
>
from_json_
tuple
_impl
(
BasicJsonType
&&
j
,
identity_tag
<
std
::
pair
<
A1
,
A2
>>
/*unused*/
,
priority_tag
<
0
>
/*unused*/
)
{
return
{
std
::
forward
<
BasicJsonType
>
(
j
).
at
(
0
).
template
get
<
A1
>
(),
std
::
forward
<
BasicJsonType
>
(
j
).
at
(
1
).
template
get
<
A2
>
()};
}
template
<
typename
BasicJsonType
,
typename
A1
,
typename
A2
>
void
from_json_pair_impl
(
BasicJsonType
&&
j
,
std
::
pair
<
A1
,
A2
>&
p
,
priority_tag
<
1
>
/*unused*/
)
{
p
=
from_json_pair_impl
(
std
::
forward
<
BasicJsonType
>
(
j
),
identity_tag
<
std
::
pair
<
A1
,
A2
>>
{},
priority_tag
<
0
>
{});
}
template
<
typename
BasicJsonType
,
typename
PairRelatedType
>
auto
from_json
(
BasicJsonType
&&
j
,
PairRelatedType
&&
p
)
->
decltype
(
from_json_pair_impl
(
std
::
forward
<
BasicJsonType
>
(
j
),
std
::
forward
<
PairRelatedType
>
(
p
),
priority_tag
<
1
>
{}))
void
from_json_tuple_impl
(
BasicJsonType
&&
j
,
std
::
pair
<
A1
,
A2
>&
p
,
priority_tag
<
1
>
/*unused*/
)
{
if
(
JSON_HEDLEY_UNLIKELY
(
!
j
.
is_array
()))
{
JSON_THROW
(
type_error
::
create
(
302
,
"type must be array, but is "
+
std
::
string
(
j
.
type_name
())));
}
return
from_json_pair_impl
(
std
::
forward
<
BasicJsonType
>
(
j
),
std
::
forward
<
PairRelatedType
>
(
p
),
priority_tag
<
1
>
{});
}
template
<
typename
BasicJsonType
,
typename
...
Args
,
std
::
size_t
...
Idx
>
std
::
tuple
<
Args
...
>
from_json_tuple_impl_base
(
BasicJsonType
&&
j
,
index_sequence
<
Idx
...
>
/*unused*/
)
{
return
std
::
make_tuple
(
std
::
forward
<
BasicJsonType
>
(
j
).
at
(
Idx
).
template
get
<
Args
>
()...);
p
=
from_json_tuple_impl
(
std
::
forward
<
BasicJsonType
>
(
j
),
identity_tag
<
std
::
pair
<
A1
,
A2
>>
{},
priority_tag
<
0
>
{});
}
template
<
typename
BasicJsonType
,
typename
...
Args
>
std
::
tuple
<
Args
...
>
from_json_tuple_impl
(
BasicJsonType
&&
j
,
identity_tag
<
std
::
tuple
<
Args
...
>>
/*unused*/
,
priority_tag
<
0
>
/*unused*/
)
std
::
tuple
<
Args
...
>
from_json_tuple_impl
(
BasicJsonType
&&
j
,
identity_tag
<
std
::
tuple
<
Args
...
>>
/*unused*/
,
priority_tag
<
2
>
/*unused*/
)
{
return
from_json_tuple_impl_base
<
BasicJsonType
,
Args
...
>
(
std
::
forward
<
BasicJsonType
>
(
j
),
index_sequence_for
<
Args
...
>
{});
}
template
<
typename
BasicJsonType
,
typename
...
Args
>
void
from_json_tuple_impl
(
BasicJsonType
&&
j
,
std
::
tuple
<
Args
...
>&
t
,
priority_tag
<
1
>
/*unused*/
)
void
from_json_tuple_impl
(
BasicJsonType
&&
j
,
std
::
tuple
<
Args
...
>&
t
,
priority_tag
<
3
>
/*unused*/
)
{
t
=
from_json_tuple_impl_base
<
BasicJsonType
,
Args
...
>
(
std
::
forward
<
BasicJsonType
>
(
j
),
index_sequence_for
<
Args
...
>
{});
}
template
<
typename
BasicJsonType
,
typename
TupleRelated
>
auto
from_json
(
BasicJsonType
&&
j
,
TupleRelated
&&
t
)
->
decltype
(
from_json_tuple_impl
(
std
::
forward
<
BasicJsonType
>
(
j
),
std
::
forward
<
TupleRelated
>
(
t
),
priority_tag
<
1
>
{}))
->
decltype
(
from_json_tuple_impl
(
std
::
forward
<
BasicJsonType
>
(
j
),
std
::
forward
<
TupleRelated
>
(
t
),
priority_tag
<
3
>
{}))
{
if
(
JSON_HEDLEY_UNLIKELY
(
!
j
.
is_array
()))
{
...
...
@@ -3934,7 +3927,7 @@ auto from_json(BasicJsonType&& j, TupleRelated&& t)
std
::
string
(
j
.
type_name
())));
}
return
from_json_tuple_impl
(
std
::
forward
<
BasicJsonType
>
(
j
),
std
::
forward
<
TupleRelated
>
(
t
),
priority_tag
<
1
>
{});
return
from_json_tuple_impl
(
std
::
forward
<
BasicJsonType
>
(
j
),
std
::
forward
<
TupleRelated
>
(
t
),
priority_tag
<
3
>
{});
}
template
<
typename
BasicJsonType
,
typename
Key
,
typename
Value
,
typename
Compare
,
typename
Allocator
,
...
...
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