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
377995f4
Commit
377995f4
authored
May 27, 2020
by
Francois Chabot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
forcefully exclude arrays from being interpreted as pointers
parent
b9416a26
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
12 deletions
+24
-12
include/nlohmann/detail/input/input_adapters.hpp
include/nlohmann/detail/input/input_adapters.hpp
+12
-6
single_include/nlohmann/json.hpp
single_include/nlohmann/json.hpp
+12
-6
No files found.
include/nlohmann/detail/input/input_adapters.hpp
View file @
377995f4
...
...
@@ -391,12 +391,13 @@ inline input_stream_adapter input_adapter(std::istream&& stream)
using
contiguous_bytes_input_adapter
=
decltype
(
input_adapter
(
std
::
declval
<
const
char
*>
(),
std
::
declval
<
const
char
*>
()));
// Null-delimited strings, and the like.
template
<
typename
CharT
,
typename
std
::
enable_if
<
std
::
is_pointer
<
CharT
>
::
value
and
std
::
is_integral
<
typename
std
::
remove_pointer
<
CharT
>::
type
>::
value
and
sizeof
(
typename
std
::
remove_pointer
<
CharT
>::
type
)
==
1
,
int
>::
type
=
0
>
template
<
typename
CharT
,
typename
std
::
enable_if
<
std
::
is_pointer
<
CharT
>
::
value
and
!
std
::
is_array
<
CharT
>::
value
and
std
::
is_integral
<
typename
std
::
remove_pointer
<
CharT
>::
type
>::
value
and
sizeof
(
typename
std
::
remove_pointer
<
CharT
>::
type
)
==
1
,
int
>::
type
=
0
>
contiguous_bytes_input_adapter
input_adapter
(
CharT
b
)
{
auto
length
=
std
::
strlen
(
reinterpret_cast
<
const
char
*>
(
b
));
...
...
@@ -404,6 +405,11 @@ contiguous_bytes_input_adapter input_adapter(CharT b)
return
input_adapter
(
ptr
,
ptr
+
length
);
}
template
<
typename
T
,
std
::
size_t
N
>
auto
input_adapter
(
T
(
&
array
)[
N
])
->
decltype
(
input_adapter
(
array
,
array
+
N
))
{
return
input_adapter
(
array
,
array
+
N
);
}
// This class only handles inputs of input_buffer_adapter type.
// It's required so that expressions like {ptr, len} can be implicitely casted
...
...
single_include/nlohmann/json.hpp
View file @
377995f4
...
...
@@ -4813,12 +4813,13 @@ inline input_stream_adapter input_adapter(std::istream&& stream)
using
contiguous_bytes_input_adapter
=
decltype
(
input_adapter
(
std
::
declval
<
const
char
*>
(),
std
::
declval
<
const
char
*>
()));
// Null-delimited strings, and the like.
template
<
typename
CharT
,
typename
std
::
enable_if
<
std
::
is_pointer
<
CharT
>
::
value
and
std
::
is_integral
<
typename
std
::
remove_pointer
<
CharT
>::
type
>::
value
and
sizeof
(
typename
std
::
remove_pointer
<
CharT
>::
type
)
==
1
,
int
>::
type
=
0
>
template
<
typename
CharT
,
typename
std
::
enable_if
<
std
::
is_pointer
<
CharT
>
::
value
and
!
std
::
is_array
<
CharT
>::
value
and
std
::
is_integral
<
typename
std
::
remove_pointer
<
CharT
>::
type
>::
value
and
sizeof
(
typename
std
::
remove_pointer
<
CharT
>::
type
)
==
1
,
int
>::
type
=
0
>
contiguous_bytes_input_adapter
input_adapter
(
CharT
b
)
{
auto
length
=
std
::
strlen
(
reinterpret_cast
<
const
char
*>
(
b
));
...
...
@@ -4826,6 +4827,11 @@ contiguous_bytes_input_adapter input_adapter(CharT b)
return
input_adapter
(
ptr
,
ptr
+
length
);
}
template
<
typename
T
,
std
::
size_t
N
>
auto
input_adapter
(
T
(
&
array
)[
N
])
->
decltype
(
input_adapter
(
array
,
array
+
N
))
{
return
input_adapter
(
array
,
array
+
N
);
}
// This class only handles inputs of input_buffer_adapter type.
// It's required so that expressions like {ptr, len} can be implicitely casted
...
...
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