MCPcopy Create free account
hub / github.com/CppCXY/EmmyLuaCodeStyle / erase

Function erase

3rd/nlohmann_json/include/nlohmann/json.hpp:4226–4289  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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:

Callers 2

merge_patchFunction · 0.70
eraseMethod · 0.50

Calls 15

stringFunction · 0.85
createFunction · 0.70
endFunction · 0.70
is_stringFunction · 0.70
destroyFunction · 0.70
is_binaryFunction · 0.70
type_nameFunction · 0.70
is_objectFunction · 0.70
is_arrayFunction · 0.70
sizeFunction · 0.70
deallocateFunction · 0.50
is_beginMethod · 0.45

Tested by

no test coverage detected