Merge pull request #807 from theodelrieu/fix/805
add forwarding references to json_ref constructor
This commit is contained in:
commit
73d0095154
2 changed files with 25 additions and 1 deletions
|
@ -6789,7 +6789,7 @@ class json_ref
|
||||||
{}
|
{}
|
||||||
|
|
||||||
template <class... Args>
|
template <class... Args>
|
||||||
json_ref(Args... args)
|
json_ref(Args&&... args)
|
||||||
: owned_value(std::forward<Args>(args)...),
|
: owned_value(std::forward<Args>(args)...),
|
||||||
value_ref(&owned_value),
|
value_ref(&owned_value),
|
||||||
is_rvalue(true)
|
is_rvalue(true)
|
||||||
|
|
|
@ -36,6 +36,22 @@ using nlohmann::json;
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <cstdio>
|
#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")
|
TEST_CASE("regression tests")
|
||||||
{
|
{
|
||||||
SECTION("issue #60 - Double quotation mark is not parsed correctly")
|
SECTION("issue #60 - Double quotation mark is not parsed correctly")
|
||||||
|
@ -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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue