Commit 59fee54f authored by Philipp A. Hartmann's avatar Philipp A. Hartmann

GenericValue::Erase: pass ConstValueIterators

parent 9a9c6d68
...@@ -1011,7 +1011,7 @@ int z = a[0u].GetInt(); // This works too. ...@@ -1011,7 +1011,7 @@ int z = a[0u].GetInt(); // This works too.
\pre IsArray() == true && \ref Begin() <= \c pos < \ref End() \pre IsArray() == true && \ref Begin() <= \c pos < \ref End()
\return Iterator following the removed element. If the iterator pos refers to the last element, the End() iterator is returned. \return Iterator following the removed element. If the iterator pos refers to the last element, the End() iterator is returned.
*/ */
ValueIterator Erase(ValueIterator pos) { ValueIterator Erase(ConstValueIterator pos) {
return Erase(pos, pos + 1); return Erase(pos, pos + 1);
} }
...@@ -1022,18 +1022,19 @@ int z = a[0u].GetInt(); // This works too. ...@@ -1022,18 +1022,19 @@ int z = a[0u].GetInt(); // This works too.
\pre IsArray() == true && \ref Begin() <= \c first <= \c last <= \ref End() \pre IsArray() == true && \ref Begin() <= \c first <= \c last <= \ref End()
\return Iterator following the last removed element. \return Iterator following the last removed element.
*/ */
ValueIterator Erase(ValueIterator first, ValueIterator last) { ValueIterator Erase(ConstValueIterator first, ConstValueIterator last) {
RAPIDJSON_ASSERT(IsArray()); RAPIDJSON_ASSERT(IsArray());
RAPIDJSON_ASSERT(data_.a.size > 0); RAPIDJSON_ASSERT(data_.a.size > 0);
RAPIDJSON_ASSERT(data_.a.elements != 0); RAPIDJSON_ASSERT(data_.a.elements != 0);
RAPIDJSON_ASSERT(first >= Begin()); RAPIDJSON_ASSERT(first >= Begin());
RAPIDJSON_ASSERT(first <= last); RAPIDJSON_ASSERT(first <= last);
RAPIDJSON_ASSERT(last <= End()); RAPIDJSON_ASSERT(last <= End());
for (ValueIterator itr = first; itr != last; ++itr) ValueIterator pos = Begin() + (first - Begin());
for (ValueIterator itr = pos; itr != last; ++itr)
itr->~GenericValue(); itr->~GenericValue();
memmove(first, last, (End() - last) * sizeof(GenericValue)); memmove(pos, last, (End() - last) * sizeof(GenericValue));
data_.a.size -= (last - first); data_.a.size -= (last - first);
return first; return pos;
} }
//@} //@}
......
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