split set_parent function

parent 10751d11
...@@ -132,7 +132,7 @@ struct external_constructor<value_t::array> ...@@ -132,7 +132,7 @@ struct external_constructor<value_t::array>
{ {
j.m_type = value_t::array; j.m_type = value_t::array;
j.m_value = arr; j.m_value = arr;
j.set_parent(j, true); j.set_parents();
j.assert_invariant(); j.assert_invariant();
} }
...@@ -141,7 +141,7 @@ struct external_constructor<value_t::array> ...@@ -141,7 +141,7 @@ struct external_constructor<value_t::array>
{ {
j.m_type = value_t::array; j.m_type = value_t::array;
j.m_value = std::move(arr); j.m_value = std::move(arr);
j.set_parent(j, true); j.set_parents();
j.assert_invariant(); j.assert_invariant();
} }
...@@ -154,7 +154,7 @@ struct external_constructor<value_t::array> ...@@ -154,7 +154,7 @@ struct external_constructor<value_t::array>
using std::end; using std::end;
j.m_type = value_t::array; j.m_type = value_t::array;
j.m_value.array = j.template create<typename BasicJsonType::array_t>(begin(arr), end(arr)); j.m_value.array = j.template create<typename BasicJsonType::array_t>(begin(arr), end(arr));
j.set_parent(j, true); j.set_parents();
j.assert_invariant(); j.assert_invariant();
} }
...@@ -185,7 +185,7 @@ struct external_constructor<value_t::array> ...@@ -185,7 +185,7 @@ struct external_constructor<value_t::array>
{ {
std::copy(std::begin(arr), std::end(arr), j.m_value.array->begin()); std::copy(std::begin(arr), std::end(arr), j.m_value.array->begin());
} }
j.set_parent(j, true); j.set_parents();
j.assert_invariant(); j.assert_invariant();
} }
}; };
...@@ -198,7 +198,7 @@ struct external_constructor<value_t::object> ...@@ -198,7 +198,7 @@ struct external_constructor<value_t::object>
{ {
j.m_type = value_t::object; j.m_type = value_t::object;
j.m_value = obj; j.m_value = obj;
j.set_parent(j, true); j.set_parents();
j.assert_invariant(); j.assert_invariant();
} }
...@@ -207,7 +207,7 @@ struct external_constructor<value_t::object> ...@@ -207,7 +207,7 @@ struct external_constructor<value_t::object>
{ {
j.m_type = value_t::object; j.m_type = value_t::object;
j.m_value = std::move(obj); j.m_value = std::move(obj);
j.set_parent(j, true); j.set_parents();
j.assert_invariant(); j.assert_invariant();
} }
...@@ -220,7 +220,7 @@ struct external_constructor<value_t::object> ...@@ -220,7 +220,7 @@ struct external_constructor<value_t::object>
j.m_type = 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.m_value.object = j.template create<typename BasicJsonType::object_t>(begin(obj), end(obj));
j.set_parent(j, true); j.set_parents();
j.assert_invariant(); j.assert_invariant();
} }
}; };
......
...@@ -236,7 +236,7 @@ class json_sax_dom_parser ...@@ -236,7 +236,7 @@ class json_sax_dom_parser
bool end_object() bool end_object()
{ {
ref_stack.back()->set_parent(*ref_stack.back(), true); ref_stack.back()->set_parents();
ref_stack.pop_back(); ref_stack.pop_back();
return true; return true;
} }
...@@ -255,7 +255,7 @@ class json_sax_dom_parser ...@@ -255,7 +255,7 @@ class json_sax_dom_parser
bool end_array() bool end_array()
{ {
ref_stack.back()->set_parent(*ref_stack.back(), true); ref_stack.back()->set_parents();
ref_stack.pop_back(); ref_stack.pop_back();
return true; return true;
} }
...@@ -437,7 +437,7 @@ class json_sax_dom_callback_parser ...@@ -437,7 +437,7 @@ class json_sax_dom_callback_parser
} }
else else
{ {
ref_stack.back()->set_parent(*ref_stack.back(), true); ref_stack.back()->set_parents();
} }
} }
...@@ -488,7 +488,7 @@ class json_sax_dom_callback_parser ...@@ -488,7 +488,7 @@ class json_sax_dom_callback_parser
keep = callback(static_cast<int>(ref_stack.size()) - 1, parse_event_t::array_end, *ref_stack.back()); keep = callback(static_cast<int>(ref_stack.size()) - 1, parse_event_t::array_end, *ref_stack.back());
if (keep) if (keep)
{ {
ref_stack.back()->set_parent(*ref_stack.back(), true); ref_stack.back()->set_parents();
} }
else else
{ {
......
...@@ -1258,44 +1258,42 @@ class basic_json ...@@ -1258,44 +1258,42 @@ class basic_json
#endif #endif
} }
reference set_parent(reference j, bool recursive) void set_parents()
{ {
#if JSON_DIAGNOSTICS #if JSON_DIAGNOSTICS
if (recursive) switch (m_type)
{ {
switch (m_type) case value_t::array:
{ {
case value_t::array: for (auto& element : *m_value.array)
{ {
for (auto& element : *m_value.array) element.m_parent = this;
{
element.m_parent = this;
}
break;
} }
break;
}
case value_t::object: case value_t::object:
{
for (auto& element : *m_value.object)
{ {
for (auto& element : *m_value.object) element.second.m_parent = this;
{
element.second.m_parent = this;
}
break;
} }
break;
default:
break;
} }
default:
break;
} }
else #endif
{ }
j.m_parent = this;
} reference set_parent(reference j)
{
#if JSON_DIAGNOSTICS
j.m_parent = this;
#else #else
static_cast<void>(j); static_cast<void>(j);
static_cast<void>(recursive);
#endif #endif
return j; return j;
} }
...@@ -1513,7 +1511,7 @@ class basic_json ...@@ -1513,7 +1511,7 @@ class basic_json
std::forward<CompatibleType>(val)))) std::forward<CompatibleType>(val))))
{ {
JSONSerializer<U>::to_json(*this, std::forward<CompatibleType>(val)); JSONSerializer<U>::to_json(*this, std::forward<CompatibleType>(val));
set_parent(*this, true); set_parents();
assert_invariant(); assert_invariant();
} }
...@@ -1592,7 +1590,7 @@ class basic_json ...@@ -1592,7 +1590,7 @@ class basic_json
default: // LCOV_EXCL_LINE default: // LCOV_EXCL_LINE
JSON_ASSERT(false); // LCOV_EXCL_LINE JSON_ASSERT(false); // LCOV_EXCL_LINE
} }
set_parent(*this, true); set_parents();
assert_invariant(); assert_invariant();
} }
...@@ -1719,7 +1717,7 @@ class basic_json ...@@ -1719,7 +1717,7 @@ class basic_json
m_value.array = create<array_t>(init.begin(), init.end()); m_value.array = create<array_t>(init.begin(), init.end());
} }
set_parent(*this, true); set_parents();
assert_invariant(); assert_invariant();
} }
...@@ -1929,7 +1927,7 @@ class basic_json ...@@ -1929,7 +1927,7 @@ class basic_json
: m_type(value_t::array) : m_type(value_t::array)
{ {
m_value.array = create<array_t>(cnt, val); m_value.array = create<array_t>(cnt, val);
set_parent(*this, true); set_parents();
assert_invariant(); assert_invariant();
} }
...@@ -2082,7 +2080,7 @@ class basic_json ...@@ -2082,7 +2080,7 @@ class basic_json
JSON_THROW(invalid_iterator::create(206, "cannot construct with iterators from " + std::string(first.m_object->type_name()), diagnostics_t())); JSON_THROW(invalid_iterator::create(206, "cannot construct with iterators from " + std::string(first.m_object->type_name()), diagnostics_t()));
} }
set_parent(*this, true); set_parents();
assert_invariant(); assert_invariant();
} }
...@@ -2181,7 +2179,7 @@ class basic_json ...@@ -2181,7 +2179,7 @@ class basic_json
break; break;
} }
set_parent(*this, true); set_parents();
assert_invariant(); assert_invariant();
} }
...@@ -2222,7 +2220,7 @@ class basic_json ...@@ -2222,7 +2220,7 @@ class basic_json
other.m_type = value_t::null; other.m_type = value_t::null;
other.m_value = {}; other.m_value = {};
set_parent(*this, true); set_parents();
assert_invariant(); assert_invariant();
} }
...@@ -2263,7 +2261,7 @@ class basic_json ...@@ -2263,7 +2261,7 @@ class basic_json
swap(m_type, other.m_type); swap(m_type, other.m_type);
swap(m_value, other.m_value); swap(m_value, other.m_value);
set_parent(*this, true); set_parents();
assert_invariant(); assert_invariant();
return *this; return *this;
} }
...@@ -3388,7 +3386,7 @@ class basic_json ...@@ -3388,7 +3386,7 @@ class basic_json
{ {
JSON_TRY JSON_TRY
{ {
return set_parent(m_value.array->at(idx), false); return set_parent(m_value.array->at(idx));
} }
JSON_CATCH (std::out_of_range&) JSON_CATCH (std::out_of_range&)
{ {
...@@ -3486,7 +3484,7 @@ class basic_json ...@@ -3486,7 +3484,7 @@ class basic_json
{ {
JSON_TRY JSON_TRY
{ {
return set_parent(m_value.object->at(key), false); return set_parent(m_value.object->at(key));
} }
JSON_CATCH (std::out_of_range&) JSON_CATCH (std::out_of_range&)
{ {
...@@ -3684,7 +3682,7 @@ class basic_json ...@@ -3684,7 +3682,7 @@ class basic_json
// operator[] only works for objects // operator[] only works for objects
if (JSON_HEDLEY_LIKELY(is_object())) if (JSON_HEDLEY_LIKELY(is_object()))
{ {
return set_parent(m_value.object->operator[](key), false); return set_parent(m_value.object->operator[](key));
} }
JSON_THROW(type_error::create(305, "cannot use operator[] with a string argument with " + std::string(type_name()), diagnostics_t(*this))); JSON_THROW(type_error::create(305, "cannot use operator[] with a string argument with " + std::string(type_name()), diagnostics_t(*this)));
...@@ -3774,7 +3772,7 @@ class basic_json ...@@ -3774,7 +3772,7 @@ class basic_json
// at only works for objects // at only works for objects
if (JSON_HEDLEY_LIKELY(is_object())) if (JSON_HEDLEY_LIKELY(is_object()))
{ {
return set_parent(m_value.object->operator[](key), false); return set_parent(m_value.object->operator[](key));
} }
JSON_THROW(type_error::create(305, "cannot use operator[] with a string argument with " + std::string(type_name()), diagnostics_t(*this))); JSON_THROW(type_error::create(305, "cannot use operator[] with a string argument with " + std::string(type_name()), diagnostics_t(*this)));
...@@ -5330,7 +5328,7 @@ class basic_json ...@@ -5330,7 +5328,7 @@ class basic_json
// add element to array (move semantics) // add element to array (move semantics)
m_value.array->push_back(std::move(val)); m_value.array->push_back(std::move(val));
set_parent(m_value.array->back(), false); set_parent(m_value.array->back());
// if val is moved from, basic_json move constructor marks it null so we do not call the destructor // if val is moved from, basic_json move constructor marks it null so we do not call the destructor
} }
...@@ -5366,7 +5364,7 @@ class basic_json ...@@ -5366,7 +5364,7 @@ class basic_json
// add element to array // add element to array
m_value.array->push_back(val); m_value.array->push_back(val);
set_parent(m_value.array->back(), false); set_parent(m_value.array->back());
} }
/*! /*!
...@@ -5417,7 +5415,7 @@ class basic_json ...@@ -5417,7 +5415,7 @@ class basic_json
// add element to object // add element to object
auto res = m_value.object->insert(val); auto res = m_value.object->insert(val);
set_parent(res.first->second, false); set_parent(res.first->second);
} }
/*! /*!
...@@ -5521,10 +5519,10 @@ class basic_json ...@@ -5521,10 +5519,10 @@ class basic_json
// add element to array (perfect forwarding) // add element to array (perfect forwarding)
#ifdef JSON_HAS_CPP_17 #ifdef JSON_HAS_CPP_17
return set_parent(m_value.array->emplace_back(std::forward<Args>(args)...), false); return set_parent(m_value.array->emplace_back(std::forward<Args>(args)...));
#else #else
m_value.array->emplace_back(std::forward<Args>(args)...); m_value.array->emplace_back(std::forward<Args>(args)...);
return set_parent(m_value.array->back(), false); return set_parent(m_value.array->back());
#endif #endif
} }
...@@ -5574,7 +5572,7 @@ class basic_json ...@@ -5574,7 +5572,7 @@ class basic_json
// add element to array (perfect forwarding) // add element to array (perfect forwarding)
auto res = m_value.object->emplace(std::forward<Args>(args)...); auto res = m_value.object->emplace(std::forward<Args>(args)...);
set_parent(res.first->second, false); set_parent(res.first->second);
// create result iterator and set iterator to the result of emplace // create result iterator and set iterator to the result of emplace
auto it = begin(); auto it = begin();
...@@ -6007,7 +6005,7 @@ class basic_json ...@@ -6007,7 +6005,7 @@ class basic_json
std::swap(m_type, other.m_type); std::swap(m_type, other.m_type);
std::swap(m_value, other.m_value); std::swap(m_value, other.m_value);
set_parent(*this, true); set_parents();
assert_invariant(); assert_invariant();
} }
......
...@@ -4302,7 +4302,7 @@ struct external_constructor<value_t::array> ...@@ -4302,7 +4302,7 @@ struct external_constructor<value_t::array>
{ {
j.m_type = value_t::array; j.m_type = value_t::array;
j.m_value = arr; j.m_value = arr;
j.set_parent(j, true); j.set_parents();
j.assert_invariant(); j.assert_invariant();
} }
...@@ -4311,7 +4311,7 @@ struct external_constructor<value_t::array> ...@@ -4311,7 +4311,7 @@ struct external_constructor<value_t::array>
{ {
j.m_type = value_t::array; j.m_type = value_t::array;
j.m_value = std::move(arr); j.m_value = std::move(arr);
j.set_parent(j, true); j.set_parents();
j.assert_invariant(); j.assert_invariant();
} }
...@@ -4324,7 +4324,7 @@ struct external_constructor<value_t::array> ...@@ -4324,7 +4324,7 @@ struct external_constructor<value_t::array>
using std::end; using std::end;
j.m_type = value_t::array; j.m_type = value_t::array;
j.m_value.array = j.template create<typename BasicJsonType::array_t>(begin(arr), end(arr)); j.m_value.array = j.template create<typename BasicJsonType::array_t>(begin(arr), end(arr));
j.set_parent(j, true); j.set_parents();
j.assert_invariant(); j.assert_invariant();
} }
...@@ -4355,7 +4355,7 @@ struct external_constructor<value_t::array> ...@@ -4355,7 +4355,7 @@ struct external_constructor<value_t::array>
{ {
std::copy(std::begin(arr), std::end(arr), j.m_value.array->begin()); std::copy(std::begin(arr), std::end(arr), j.m_value.array->begin());
} }
j.set_parent(j, true); j.set_parents();
j.assert_invariant(); j.assert_invariant();
} }
}; };
...@@ -4368,7 +4368,7 @@ struct external_constructor<value_t::object> ...@@ -4368,7 +4368,7 @@ struct external_constructor<value_t::object>
{ {
j.m_type = value_t::object; j.m_type = value_t::object;
j.m_value = obj; j.m_value = obj;
j.set_parent(j, true); j.set_parents();
j.assert_invariant(); j.assert_invariant();
} }
...@@ -4377,7 +4377,7 @@ struct external_constructor<value_t::object> ...@@ -4377,7 +4377,7 @@ struct external_constructor<value_t::object>
{ {
j.m_type = value_t::object; j.m_type = value_t::object;
j.m_value = std::move(obj); j.m_value = std::move(obj);
j.set_parent(j, true); j.set_parents();
j.assert_invariant(); j.assert_invariant();
} }
...@@ -4390,7 +4390,7 @@ struct external_constructor<value_t::object> ...@@ -4390,7 +4390,7 @@ struct external_constructor<value_t::object>
j.m_type = 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.m_value.object = j.template create<typename BasicJsonType::object_t>(begin(obj), end(obj));
j.set_parent(j, true); j.set_parents();
j.assert_invariant(); j.assert_invariant();
} }
}; };
...@@ -5638,7 +5638,7 @@ class json_sax_dom_parser ...@@ -5638,7 +5638,7 @@ class json_sax_dom_parser
bool end_object() bool end_object()
{ {
ref_stack.back()->set_parent(*ref_stack.back(), true); ref_stack.back()->set_parents();
ref_stack.pop_back(); ref_stack.pop_back();
return true; return true;
} }
...@@ -5657,7 +5657,7 @@ class json_sax_dom_parser ...@@ -5657,7 +5657,7 @@ class json_sax_dom_parser
bool end_array() bool end_array()
{ {
ref_stack.back()->set_parent(*ref_stack.back(), true); ref_stack.back()->set_parents();
ref_stack.pop_back(); ref_stack.pop_back();
return true; return true;
} }
...@@ -5839,7 +5839,7 @@ class json_sax_dom_callback_parser ...@@ -5839,7 +5839,7 @@ class json_sax_dom_callback_parser
} }
else else
{ {
ref_stack.back()->set_parent(*ref_stack.back(), true); ref_stack.back()->set_parents();
} }
} }
...@@ -5890,7 +5890,7 @@ class json_sax_dom_callback_parser ...@@ -5890,7 +5890,7 @@ class json_sax_dom_callback_parser
keep = callback(static_cast<int>(ref_stack.size()) - 1, parse_event_t::array_end, *ref_stack.back()); keep = callback(static_cast<int>(ref_stack.size()) - 1, parse_event_t::array_end, *ref_stack.back());
if (keep) if (keep)
{ {
ref_stack.back()->set_parent(*ref_stack.back(), true); ref_stack.back()->set_parents();
} }
else else
{ {
...@@ -18015,44 +18015,42 @@ class basic_json ...@@ -18015,44 +18015,42 @@ class basic_json
#endif #endif
} }
reference set_parent(reference j, bool recursive) void set_parents()
{ {
#if JSON_DIAGNOSTICS #if JSON_DIAGNOSTICS
if (recursive) switch (m_type)
{ {
switch (m_type) case value_t::array:
{ {
case value_t::array: for (auto& element : *m_value.array)
{ {
for (auto& element : *m_value.array) element.m_parent = this;
{
element.m_parent = this;
}
break;
} }
break;
}
case value_t::object: case value_t::object:
{
for (auto& element : *m_value.object)
{ {
for (auto& element : *m_value.object) element.second.m_parent = this;
{
element.second.m_parent = this;
}
break;
} }
break;
default:
break;
} }
default:
break;
} }
else #endif
{ }
j.m_parent = this;
} reference set_parent(reference j)
{
#if JSON_DIAGNOSTICS
j.m_parent = this;
#else #else
static_cast<void>(j); static_cast<void>(j);
static_cast<void>(recursive);
#endif #endif
return j; return j;
} }
...@@ -18270,7 +18268,7 @@ class basic_json ...@@ -18270,7 +18268,7 @@ class basic_json
std::forward<CompatibleType>(val)))) std::forward<CompatibleType>(val))))
{ {
JSONSerializer<U>::to_json(*this, std::forward<CompatibleType>(val)); JSONSerializer<U>::to_json(*this, std::forward<CompatibleType>(val));
set_parent(*this, true); set_parents();
assert_invariant(); assert_invariant();
} }
...@@ -18349,7 +18347,7 @@ class basic_json ...@@ -18349,7 +18347,7 @@ class basic_json
default: // LCOV_EXCL_LINE default: // LCOV_EXCL_LINE
JSON_ASSERT(false); // LCOV_EXCL_LINE JSON_ASSERT(false); // LCOV_EXCL_LINE
} }
set_parent(*this, true); set_parents();
assert_invariant(); assert_invariant();
} }
...@@ -18476,7 +18474,7 @@ class basic_json ...@@ -18476,7 +18474,7 @@ class basic_json
m_value.array = create<array_t>(init.begin(), init.end()); m_value.array = create<array_t>(init.begin(), init.end());
} }
set_parent(*this, true); set_parents();
assert_invariant(); assert_invariant();
} }
...@@ -18686,7 +18684,7 @@ class basic_json ...@@ -18686,7 +18684,7 @@ class basic_json
: m_type(value_t::array) : m_type(value_t::array)
{ {
m_value.array = create<array_t>(cnt, val); m_value.array = create<array_t>(cnt, val);
set_parent(*this, true); set_parents();
assert_invariant(); assert_invariant();
} }
...@@ -18839,7 +18837,7 @@ class basic_json ...@@ -18839,7 +18837,7 @@ class basic_json
JSON_THROW(invalid_iterator::create(206, "cannot construct with iterators from " + std::string(first.m_object->type_name()), diagnostics_t())); JSON_THROW(invalid_iterator::create(206, "cannot construct with iterators from " + std::string(first.m_object->type_name()), diagnostics_t()));
} }
set_parent(*this, true); set_parents();
assert_invariant(); assert_invariant();
} }
...@@ -18938,7 +18936,7 @@ class basic_json ...@@ -18938,7 +18936,7 @@ class basic_json
break; break;
} }
set_parent(*this, true); set_parents();
assert_invariant(); assert_invariant();
} }
...@@ -18979,7 +18977,7 @@ class basic_json ...@@ -18979,7 +18977,7 @@ class basic_json
other.m_type = value_t::null; other.m_type = value_t::null;
other.m_value = {}; other.m_value = {};
set_parent(*this, true); set_parents();
assert_invariant(); assert_invariant();
} }
...@@ -19020,7 +19018,7 @@ class basic_json ...@@ -19020,7 +19018,7 @@ class basic_json
swap(m_type, other.m_type); swap(m_type, other.m_type);
swap(m_value, other.m_value); swap(m_value, other.m_value);
set_parent(*this, true); set_parents();
assert_invariant(); assert_invariant();
return *this; return *this;
} }
...@@ -20145,7 +20143,7 @@ class basic_json ...@@ -20145,7 +20143,7 @@ class basic_json
{ {
JSON_TRY JSON_TRY
{ {
return set_parent(m_value.array->at(idx), false); return set_parent(m_value.array->at(idx));
} }
JSON_CATCH (std::out_of_range&) JSON_CATCH (std::out_of_range&)
{ {
...@@ -20243,7 +20241,7 @@ class basic_json ...@@ -20243,7 +20241,7 @@ class basic_json
{ {
JSON_TRY JSON_TRY
{ {
return set_parent(m_value.object->at(key), false); return set_parent(m_value.object->at(key));
} }
JSON_CATCH (std::out_of_range&) JSON_CATCH (std::out_of_range&)
{ {
...@@ -20441,7 +20439,7 @@ class basic_json ...@@ -20441,7 +20439,7 @@ class basic_json
// operator[] only works for objects // operator[] only works for objects
if (JSON_HEDLEY_LIKELY(is_object())) if (JSON_HEDLEY_LIKELY(is_object()))
{ {
return set_parent(m_value.object->operator[](key), false); return set_parent(m_value.object->operator[](key));
} }
JSON_THROW(type_error::create(305, "cannot use operator[] with a string argument with " + std::string(type_name()), diagnostics_t(*this))); JSON_THROW(type_error::create(305, "cannot use operator[] with a string argument with " + std::string(type_name()), diagnostics_t(*this)));
...@@ -20531,7 +20529,7 @@ class basic_json ...@@ -20531,7 +20529,7 @@ class basic_json
// at only works for objects // at only works for objects
if (JSON_HEDLEY_LIKELY(is_object())) if (JSON_HEDLEY_LIKELY(is_object()))
{ {
return set_parent(m_value.object->operator[](key), false); return set_parent(m_value.object->operator[](key));
} }
JSON_THROW(type_error::create(305, "cannot use operator[] with a string argument with " + std::string(type_name()), diagnostics_t(*this))); JSON_THROW(type_error::create(305, "cannot use operator[] with a string argument with " + std::string(type_name()), diagnostics_t(*this)));
...@@ -22087,7 +22085,7 @@ class basic_json ...@@ -22087,7 +22085,7 @@ class basic_json
// add element to array (move semantics) // add element to array (move semantics)
m_value.array->push_back(std::move(val)); m_value.array->push_back(std::move(val));
set_parent(m_value.array->back(), false); set_parent(m_value.array->back());
// if val is moved from, basic_json move constructor marks it null so we do not call the destructor // if val is moved from, basic_json move constructor marks it null so we do not call the destructor
} }
...@@ -22123,7 +22121,7 @@ class basic_json ...@@ -22123,7 +22121,7 @@ class basic_json
// add element to array // add element to array
m_value.array->push_back(val); m_value.array->push_back(val);
set_parent(m_value.array->back(), false); set_parent(m_value.array->back());
} }
/*! /*!
...@@ -22174,7 +22172,7 @@ class basic_json ...@@ -22174,7 +22172,7 @@ class basic_json
// add element to object // add element to object
auto res = m_value.object->insert(val); auto res = m_value.object->insert(val);
set_parent(res.first->second, false); set_parent(res.first->second);
} }
/*! /*!
...@@ -22278,10 +22276,10 @@ class basic_json ...@@ -22278,10 +22276,10 @@ class basic_json
// add element to array (perfect forwarding) // add element to array (perfect forwarding)
#ifdef JSON_HAS_CPP_17 #ifdef JSON_HAS_CPP_17
return set_parent(m_value.array->emplace_back(std::forward<Args>(args)...), false); return set_parent(m_value.array->emplace_back(std::forward<Args>(args)...));
#else #else
m_value.array->emplace_back(std::forward<Args>(args)...); m_value.array->emplace_back(std::forward<Args>(args)...);
return set_parent(m_value.array->back(), false); return set_parent(m_value.array->back());
#endif #endif
} }
...@@ -22331,7 +22329,7 @@ class basic_json ...@@ -22331,7 +22329,7 @@ class basic_json
// add element to array (perfect forwarding) // add element to array (perfect forwarding)
auto res = m_value.object->emplace(std::forward<Args>(args)...); auto res = m_value.object->emplace(std::forward<Args>(args)...);
set_parent(res.first->second, false); set_parent(res.first->second);
// create result iterator and set iterator to the result of emplace // create result iterator and set iterator to the result of emplace
auto it = begin(); auto it = begin();
...@@ -22764,7 +22762,7 @@ class basic_json ...@@ -22764,7 +22762,7 @@ class basic_json
std::swap(m_type, other.m_type); std::swap(m_type, other.m_type);
std::swap(m_value, other.m_value); std::swap(m_value, other.m_value);
set_parent(*this, true); set_parents();
assert_invariant(); assert_invariant();
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment