mirror of
https://github.com/nlohmann/json.git
synced 2026-10-19 12:38:12 +00:00
Address the review of erase() in editable json documents
From gregmarr's review of #5630: - invalid_iterator.202 is thrown by overloads 1 and 2 only; the page said "every overload" and then excluded 3 in parentheses. - The note on links says what moves (the links after the removed element, as insert() moves them the other way) and that every iterator over the container is invalidated, not only those after the removed element. - edit.hpp compares keys with document_data::key_equals(). Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
2 files changed
+10
-9
No files matched your search
@@ -12,7 +12,7 @@
|
||||
#include <cmath> // isinf, isnan
|
||||
#include <cstddef> // size_t
|
||||
#include <cstdint> // int64_t, uint8_t, uint32_t, uint64_t
|
||||
#include <cstring> // memcmp, memmove
|
||||
#include <cstring> // memmove
|
||||
#include <limits> // numeric_limits
|
||||
#include <string> // string, to_string
|
||||
#include <type_traits> // decay, enable_if, integral_constant, is_arithmetic, is_convertible, is_floating_point, is_same, is_signed
|
||||
@@ -313,7 +313,7 @@ class editor
|
||||
|
||||
bool key_equals(const node& k, string_view_t key) const noexcept
|
||||
{
|
||||
return k.len == key.size() && (key.size() == 0 || std::memcmp(m_doc.str(k), key.data(), key.size()) == 0);
|
||||
return m_doc.key_equals(k, key.data(), key.size());
|
||||
}
|
||||
|
||||
/// remove the members with this key (all, or all but the first) from an object
|
||||
|
||||
Reference in new issue
Block a user