json_view: fix a scalar set() through a view of an erased value (#6132)
Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
1 parent
abbc29963a
commit
a1284028b2
6 files changed
+181
-8
No files matched your search
@@ -100,7 +100,8 @@ points apply to every edit:
|
||||
[`root()`](root.md). New values (and the element sequences of an edited array/object) go to storage owned by the
|
||||
document, allocated on demand.
|
||||
- **A view keeps referring to the same value.** After [`set`](set.md) replaces the value a view refers to, that view
|
||||
sees the new value; a view of a value that a later edit replaces or drops keeps showing what it last held. An edit
|
||||
sees the new value; a view of a value that a later edit replaces or drops keeps showing what it last held. Such a
|
||||
view can still be edited: the edit changes only that detached value, never anything reachable from `root()`. An edit
|
||||
of an array or object, however, **invalidates the iterators taken over it** (its members may now live in a
|
||||
different sequence), and a string obtained with [`get_string()`](../basic_json_view/get_string.md) stays valid even
|
||||
as further edits happen (earlier buffers of edited text are kept alive, not overwritten).
|
||||
|
||||
@@ -164,7 +164,9 @@ general.
|
||||
The same switch happens, for the same reason, when overload 1. replaces a multi-node array/object value with a
|
||||
scalar: the *parent's* element sequence is what has to switch to links, not `target` itself, because the parent
|
||||
originally stepped over `target`'s whole subtree by its node count, which no longer applies once `target` is a
|
||||
one-node scalar.
|
||||
one-node scalar. This also holds when `target` is no longer part of the document (an edit erased or replaced it, or
|
||||
a value that contains it): if the container that `target` was in still uses its parsed layout, it switches to links
|
||||
(otherwise nothing steps over `target` any more), and only the dropped values change.
|
||||
|
||||
## Examples
|
||||
|
||||
|
||||
Reference in new issue
Block a user