🐛 fix invariants

This commit is contained in:
Niels Lohmann
2021-01-10 22:40:50 +01:00
parent 9d0150c234
commit ff57bdcc8b
5 changed files with 118 additions and 60 deletions
@@ -132,6 +132,7 @@ struct external_constructor<value_t::array>
{
j.m_type = value_t::array;
j.m_value = arr;
j.set_parent(j, true);
j.assert_invariant();
}
@@ -140,6 +141,7 @@ struct external_constructor<value_t::array>
{
j.m_type = value_t::array;
j.m_value = std::move(arr);
j.set_parent(j, true);
j.assert_invariant();
}
@@ -152,6 +154,7 @@ struct external_constructor<value_t::array>
using std::end;
j.m_type = value_t::array;
j.m_value.array = j.template create<typename BasicJsonType::array_t>(begin(arr), end(arr));
j.set_parent(j, true);
j.assert_invariant();
}
@@ -164,6 +167,9 @@ struct external_constructor<value_t::array>
for (const bool x : arr)
{
j.m_value.array->push_back(x);
#if JSON_DIAGNOSTICS
j.m_value.array->back().m_parent = &j;
#endif
}
j.assert_invariant();
}
@@ -179,6 +185,7 @@ struct external_constructor<value_t::array>
{
std::copy(std::begin(arr), std::end(arr), j.m_value.array->begin());
}
j.set_parent(j, true);
j.assert_invariant();
}
};
@@ -191,6 +198,7 @@ struct external_constructor<value_t::object>
{
j.m_type = value_t::object;
j.m_value = obj;
j.set_parent(j, true);
j.assert_invariant();
}
@@ -199,6 +207,7 @@ struct external_constructor<value_t::object>
{
j.m_type = value_t::object;
j.m_value = std::move(obj);
j.set_parent(j, true);
j.assert_invariant();
}
@@ -211,6 +220,7 @@ struct external_constructor<value_t::object>
j.m_type = value_t::object;
j.m_value.object = j.template create<typename BasicJsonType::object_t>(begin(obj), end(obj));
j.set_parent(j, true);
j.assert_invariant();
}
};