1
0
mirror of https://github.com/nlohmann/json.git synced 2025-08-09 05:22:48 +03:00

Fix parent update for diagnostics with ordered_json (#2963)

🐛 fix parent update for diagnostics with ordered_json
This commit is contained in:
Niels Lohmann
2021-08-22 20:30:20 +02:00
committed by GitHub
parent f03127eb69
commit c753165db6
4 changed files with 76 additions and 0 deletions

View File

@@ -1336,6 +1336,21 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
}
}
// ordered_json uses a vector internally, so pointers could have
// been invalidated; see https://github.com/nlohmann/json/issues/2962
#ifdef JSON_HEDLEY_MSVC_VERSION
#pragma warning(push )
#pragma warning(disable : 4127) // ignore warning to replace if with if constexpr
#endif
if (detail::is_ordered_map<object_t>::value)
{
set_parents();
return j;
}
#ifdef JSON_HEDLEY_MSVC_VERSION
#pragma warning( pop )
#endif
j.m_parent = this;
#else
static_cast<void>(j);