| 19919 | } |
| 19920 | |
| 19921 | reference set_parent(reference j, std::size_t old_capacity = static_cast<std::size_t>(-1)) |
| 19922 | { |
| 19923 | #if JSON_DIAGNOSTICS |
| 19924 | if (old_capacity != static_cast<std::size_t>(-1)) |
| 19925 | { |
| 19926 | // see https://github.com/nlohmann/json/issues/2838 |
| 19927 | JSON_ASSERT(type() == value_t::array); |
| 19928 | if (JSON_HEDLEY_UNLIKELY(m_value.array->capacity() != old_capacity)) |
| 19929 | { |
| 19930 | // capacity has changed: update all parents |
| 19931 | set_parents(); |
| 19932 | return j; |
| 19933 | } |
| 19934 | } |
| 19935 | |
| 19936 | // ordered_json uses a vector internally, so pointers could have |
| 19937 | // been invalidated; see https://github.com/nlohmann/json/issues/2962 |
| 19938 | #ifdef JSON_HEDLEY_MSVC_VERSION |
| 19939 | #pragma warning(push ) |
| 19940 | #pragma warning(disable : 4127) // ignore warning to replace if with if constexpr |
| 19941 | #endif |
| 19942 | if (detail::is_ordered_map<object_t>::value) |
| 19943 | { |
| 19944 | set_parents(); |
| 19945 | return j; |
| 19946 | } |
| 19947 | #ifdef JSON_HEDLEY_MSVC_VERSION |
| 19948 | #pragma warning( pop ) |
| 19949 | #endif |
| 19950 | |
| 19951 | j.m_parent = this; |
| 19952 | #else |
| 19953 | static_cast<void>(j); |
| 19954 | static_cast<void>(old_capacity); |
| 19955 | #endif |
| 19956 | return j; |
| 19957 | } |
| 19958 | |
| 19959 | public: |
| 19960 | ////////////////////////// |
no test coverage detected