Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion src/json.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6789,7 +6789,7 @@ class json_ref
{}

template <class... Args>
json_ref(Args... args)
json_ref(Args&&... args)
: owned_value(std::forward<Args>(args)...),
value_ref(&owned_value),
is_rvalue(true)
Expand Down
24 changes: 24 additions & 0 deletions test/src/unit-regression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,22 @@ using nlohmann::json;
#include <list>
#include <cstdio>

namespace
{
struct nocopy
{
nocopy() = default;
nocopy(const nocopy &) = delete;

int val = 0;

friend void to_json(json& j, const nocopy& n)
{
j = {{"val", n.val}};
}
};
}

TEST_CASE("regression tests")
{
SECTION("issue #60 - Double quotation mark is not parsed correctly")
Expand Down Expand Up @@ -1282,4 +1298,12 @@ TEST_CASE("regression tests")
}
}
*/

SECTION("issue #805 - copy constructor is used with std::initializer_list constructor.")
{
nocopy n;
json j;
j = {{"nocopy", n}};
CHECK(j["nocopy"]["val"] == 0);
}
}