👌 fix operator[]

This commit is contained in:
Niels Lohmann 2021-01-08 11:21:41 +01:00
parent 04a0a07159
commit e4af1ddb18
No known key found for this signature in database
GPG Key ID: 7F3CEA63AE251B69

View File

@ -3653,6 +3653,13 @@ class basic_json
// fill up array with null values if given idx is outside range
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
// set parent for values added above
for (auto i = previous_size; i <= idx; ++i)