mirror of
https://github.com/nlohmann/json.git
synced 2026-10-18 20:18:12 +00:00
👌 fix operator[]
This commit is contained in:
1 file changed
+7
@@ -3653,6 +3653,13 @@ class basic_json
|
|||||||
// fill up array with null values if given idx is outside range
|
// fill up array with null values if given idx is outside range
|
||||||
if (idx >= m_value.array->size())
|
if (idx >= m_value.array->size())
|
||||||
{
|
{
|
||||||
|
#if JSON_DIAGNOSTICS
|
||||||
|
// remember array size before resizing
|
||||||
|
const auto previous_size = m_value.array->size();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
m_value.array->resize(idx + 1);
|
||||||
|
|
||||||
#if JSON_DIAGNOSTICS
|
#if JSON_DIAGNOSTICS
|
||||||
// set parent for values added above
|
// set parent for values added above
|
||||||
for (auto i = previous_size; i <= idx; ++i)
|
for (auto i = previous_size; i <= idx; ++i)
|
||||||
|
|||||||
Reference in new issue
Block a user