Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for deserialization of STL containers of non-default constructable types (fixes #2574). #2576

Merged
Merged
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Updated comments as requested.
AnthonyVH committed Jan 23, 2021

Verified

This commit was signed with the committer’s verified signature.
wezm Wesley Moore
commit 848927ae90376d6e1e383bbd40073cf1aa09190a
4 changes: 2 additions & 2 deletions include/nlohmann/adl_serializer.hpp
Original file line number Diff line number Diff line change
@@ -20,7 +20,7 @@ struct adl_serializer
This function is usually called by the `get()` function of the
@ref basic_json class (either explicit or via conversion operators).

@note This function is chosen for value types which can be default constructed.
@note This function is chosen for default-constructible value types.

@param[in] j JSON value to read from
@param[in,out] val value to write to
@@ -39,7 +39,7 @@ struct adl_serializer
This function is usually called by the `get()` function of the
@ref basic_json class (either explicit or via conversion operators).

@note This function is chosen for value types which can not be default constructed.
@note This function is chosen for value types which are not default-constructible.

@param[in] j JSON value to read from

1 change: 1 addition & 0 deletions include/nlohmann/detail/meta/type_traits.hpp
Original file line number Diff line number Diff line change
@@ -149,6 +149,7 @@ struct has_to_json < BasicJsonType, T, enable_if_t < !is_basic_json<T>::value >>
///////////////////
// is_ functions //
///////////////////

// https://en.cppreference.com/w/cpp/types/conjunction
AnthonyVH marked this conversation as resolved.
Show resolved Hide resolved
template<class...> struct conjunction : std::true_type { };
template<class B1> struct conjunction<B1> : B1 { };
5 changes: 3 additions & 2 deletions single_include/nlohmann/json.hpp
Original file line number Diff line number Diff line change
@@ -3185,6 +3185,7 @@ struct has_to_json < BasicJsonType, T, enable_if_t < !is_basic_json<T>::value >>
///////////////////
// is_ functions //
///////////////////

// https://en.cppreference.com/w/cpp/types/conjunction
template<class...> struct conjunction : std::true_type { };
template<class B1> struct conjunction<B1> : B1 { };
@@ -4568,7 +4569,7 @@ struct adl_serializer
This function is usually called by the `get()` function of the
@ref basic_json class (either explicit or via conversion operators).

@note This function is chosen for value types which can be default constructed.
@note This function is chosen for default-constructible value types.

@param[in] j JSON value to read from
@param[in,out] val value to write to
@@ -4587,7 +4588,7 @@ struct adl_serializer
This function is usually called by the `get()` function of the
@ref basic_json class (either explicit or via conversion operators).

@note This function is chosen for value types which can not be default constructed.
@note This function is chosen for value types which are not default-constructible.

@param[in] j JSON value to read from

1 change: 1 addition & 0 deletions test/src/unit-regression2.cpp
Original file line number Diff line number Diff line change
@@ -136,6 +136,7 @@ struct NotSerializableData
/////////////////////////////////////////////////////////////////////
// for #2574
/////////////////////////////////////////////////////////////////////

struct NonDefaultConstructible
AnthonyVH marked this conversation as resolved.
Show resolved Hide resolved
{
explicit NonDefaultConstructible (int x) : x(x) { }