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
dd672939
Unverified
Commit
dd672939
authored
Oct 12, 2018
by
Niels Lohmann
Committed by
GitHub
Oct 12, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1294 from theodelrieu/fix/json_ref_ctor
add constraints for variadic json_ref constructors
parents
e4262192
11fecc25
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
8 deletions
+33
-8
include/nlohmann/detail/json_ref.hpp
include/nlohmann/detail/json_ref.hpp
+8
-4
single_include/nlohmann/json.hpp
single_include/nlohmann/json.hpp
+9
-4
test/src/unit-regression.cpp
test/src/unit-regression.cpp
+16
-0
No files found.
include/nlohmann/detail/json_ref.hpp
View file @
dd672939
...
...
@@ -3,6 +3,8 @@
#include <initializer_list>
#include <utility>
#include <nlohmann/detail/meta/type_traits.hpp>
namespace
nlohmann
{
namespace
detail
...
...
@@ -25,10 +27,12 @@ class json_ref
:
owned_value
(
init
),
value_ref
(
&
owned_value
),
is_rvalue
(
true
)
{}
template
<
class
...
Args
>
json_ref
(
Args
&&
...
args
)
:
owned_value
(
std
::
forward
<
Args
>
(
args
)...),
value_ref
(
&
owned_value
),
is_rvalue
(
true
)
{}
template
<
class
...
Args
,
enable_if_t
<
std
::
is_constructible
<
value_type
,
Args
...>
::
value
,
int
>
=
0
>
json_ref
(
Args
&&
...
args
)
:
owned_value
(
std
::
forward
<
Args
>
(
args
)...),
value_ref
(
&
owned_value
),
is_rvalue
(
true
)
{}
// class should be movable only
json_ref
(
json_ref
&&
)
=
default
;
...
...
single_include/nlohmann/json.hpp
View file @
dd672939
...
...
@@ -10591,6 +10591,9 @@ class serializer
#include <initializer_list>
#include <utility>
// #include <nlohmann/detail/meta/type_traits.hpp>
namespace
nlohmann
{
namespace
detail
...
...
@@ -10613,10 +10616,12 @@ class json_ref
:
owned_value
(
init
),
value_ref
(
&
owned_value
),
is_rvalue
(
true
)
{}
template
<
class
...
Args
>
json_ref
(
Args
&&
...
args
)
:
owned_value
(
std
::
forward
<
Args
>
(
args
)...),
value_ref
(
&
owned_value
),
is_rvalue
(
true
)
{}
template
<
class
...
Args
,
enable_if_t
<
std
::
is_constructible
<
value_type
,
Args
...>
::
value
,
int
>
=
0
>
json_ref
(
Args
&&
...
args
)
:
owned_value
(
std
::
forward
<
Args
>
(
args
)...),
value_ref
(
&
owned_value
),
is_rvalue
(
true
)
{}
// class should be movable only
json_ref
(
json_ref
&&
)
=
default
;
...
...
test/src/unit-regression.cpp
View file @
dd672939
...
...
@@ -33,6 +33,14 @@ SOFTWARE.
#include <nlohmann/json.hpp>
using
nlohmann
::
json
;
#if (defined(__cplusplus) && __cplusplus >= 201703L) || (defined(_HAS_CXX17) && _HAS_CXX17 == 1) // fix for issue #464
#define JSON_HAS_CPP_17
#endif
#ifdef JSON_HAS_CPP_17
#include <variant>
#endif
#include "fifo_map.hpp"
#include <fstream>
...
...
@@ -1649,4 +1657,12 @@ TEST_CASE("regression tests")
CHECK
(
diffs
.
size
()
==
1
);
// Note the change here, was 2
}
#ifdef JSON_HAS_CPP_17
SECTION
(
"issue #1292 - Serializing std::variant causes stack overflow"
)
{
static_assert
(
not
std
::
is_constructible
<
json
,
std
::
variant
<
int
,
float
>>::
value
,
""
);
}
#endif
}
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