1
0
mirror of https://github.com/nlohmann/json.git synced 2025-07-28 12:02:00 +03:00

🐛 fix bug in move constructor

This commit is contained in:
Niels Lohmann
2021-01-03 20:06:32 +01:00
parent ec0b1798bc
commit 294fa343d5
3 changed files with 57 additions and 5 deletions

View File

@ -1873,9 +1873,9 @@ class basic_json
{
m_value.array = create<array_t>(cnt, val);
#if JSON_DIAGNOSTICS
for (auto& entry : *m_value.array)
for (auto& element : *m_value.array)
{
entry.m_parent = this;
element.m_parent = this;
}
#endif
assert_invariant();
@ -2196,6 +2196,32 @@ class basic_json
other.m_type = value_t::null;
other.m_value = {};
#if JSON_DIAGNOSTICS
switch (m_type)
{
case value_t::array:
{
for (auto& element : *m_value.array)
{
element.m_parent = this;
}
break;
}
case value_t::object:
{
for (auto& element : *m_value.object)
{
element.second.m_parent = this;
}
break;
}
default:
break;
}
#endif
assert_invariant();
}