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
15e757c4
Unverified
Commit
15e757c4
authored
Aug 27, 2017
by
Niels Lohmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
🔨
trying to fix memory issue with valarray
parent
0e94ba88
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
7 deletions
+3
-7
src/json.hpp
src/json.hpp
+3
-7
No files found.
src/json.hpp
View file @
15e757c4
...
...
@@ -667,11 +667,10 @@ struct external_constructor<value_t::array>
enable_if_t
<
std
::
is_convertible
<
T
,
BasicJsonType
>
::
value
,
int
>
=
0
>
static
void
construct
(
BasicJsonType
&
j
,
const
std
::
valarray
<
T
>&
arr
)
{
using
std
::
begin
;
using
std
::
end
;
j
.
m_type
=
value_t
::
array
;
j
.
m_value
=
value_t
::
array
;
j
.
m_value
.
array
=
j
.
template
create
<
typename
BasicJsonType
::
array_t
>(
begin
(
arr
),
end
(
arr
));
j
.
m_value
.
array
->
resize
(
arr
.
size
());
std
::
copy
(
std
::
begin
(
arr
),
std
::
end
(
arr
),
j
.
m_value
.
array
->
begin
());
j
.
assert_invariant
();
}
};
...
...
@@ -1112,10 +1111,7 @@ void from_json(const BasicJsonType& j, std::valarray<T>& l)
JSON_THROW
(
type_error
::
create
(
302
,
"type must be array, but is "
+
std
::
string
(
j
.
type_name
())));
}
l
.
resize
(
j
.
size
());
for
(
size_t
i
=
0
;
i
<
j
.
size
();
++
i
)
{
l
[
i
]
=
j
[
i
];
}
std
::
copy
(
j
.
m_value
.
array
->
begin
(),
j
.
m_value
.
array
->
end
(),
std
::
begin
(
l
));
}
template
<
typename
BasicJsonType
,
typename
CompatibleArrayType
>
...
...
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