| 4224 | std::is_same<IteratorType, typename basic_json_t::const_iterator>::value, int >::type |
| 4225 | = 0 > |
| 4226 | IteratorType erase(IteratorType pos) |
| 4227 | { |
| 4228 | // make sure iterator fits the current value |
| 4229 | if (JSON_HEDLEY_UNLIKELY(this != pos.m_object)) |
| 4230 | { |
| 4231 | JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value", *this)); |
| 4232 | } |
| 4233 | |
| 4234 | IteratorType result = end(); |
| 4235 | |
| 4236 | switch (m_type) |
| 4237 | { |
| 4238 | case value_t::boolean: |
| 4239 | case value_t::number_float: |
| 4240 | case value_t::number_integer: |
| 4241 | case value_t::number_unsigned: |
| 4242 | case value_t::string: |
| 4243 | case value_t::binary: |
| 4244 | { |
| 4245 | if (JSON_HEDLEY_UNLIKELY(!pos.m_it.primitive_iterator.is_begin())) |
| 4246 | { |
| 4247 | JSON_THROW(invalid_iterator::create(205, "iterator out of range", *this)); |
| 4248 | } |
| 4249 | |
| 4250 | if (is_string()) |
| 4251 | { |
| 4252 | AllocatorType<string_t> alloc; |
| 4253 | std::allocator_traits<decltype(alloc)>::destroy(alloc, m_value.string); |
| 4254 | std::allocator_traits<decltype(alloc)>::deallocate(alloc, m_value.string, 1); |
| 4255 | m_value.string = nullptr; |
| 4256 | } |
| 4257 | else if (is_binary()) |
| 4258 | { |
| 4259 | AllocatorType<binary_t> alloc; |
| 4260 | std::allocator_traits<decltype(alloc)>::destroy(alloc, m_value.binary); |
| 4261 | std::allocator_traits<decltype(alloc)>::deallocate(alloc, m_value.binary, 1); |
| 4262 | m_value.binary = nullptr; |
| 4263 | } |
| 4264 | |
| 4265 | m_type = value_t::null; |
| 4266 | assert_invariant(); |
| 4267 | break; |
| 4268 | } |
| 4269 | |
| 4270 | case value_t::object: |
| 4271 | { |
| 4272 | result.m_it.object_iterator = m_value.object->erase(pos.m_it.object_iterator); |
| 4273 | break; |
| 4274 | } |
| 4275 | |
| 4276 | case value_t::array: |
| 4277 | { |
| 4278 | result.m_it.array_iterator = m_value.array->erase(pos.m_it.array_iterator); |
| 4279 | break; |
| 4280 | } |
| 4281 | |
| 4282 | case value_t::null: |
| 4283 | case value_t::discarded: |
no test coverage detected