json_view: node_kind in the node writers, spell out read_only, comment fixes

The builder and the edit functions take and store a node_kind instead of
casting a value_t; the numbering assertions and the comments now speak of
node_kind, and the link kind notes that it follows value_t::discarded.
The read-only aliases name view_mode::read_only like the editable ones.
view_mode.md says the mode is a compile-time property of the type.

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
Niels Lohmann committed 2026-10-26 07:12:05 +01:00
1 parent 266432ea65
commit 20e022655d
10 files changed
+121 -121

No files matched your search

+1 -1
View File
@@ -3,7 +3,7 @@
<small>Defined in header `<nlohmann/json_view.hpp>`</small>
```cpp
using json_document = basic_json_document<json>;
using json_document = basic_json_document<json, view_mode::read_only>;
```
This type is a [`basic_json_document`](basic_json_document/index.md) of the default [`json`](json.md)
+1 -1
View File
@@ -3,7 +3,7 @@
<small>Defined in header `<nlohmann/json_view.hpp>`</small>
```cpp
using json_view = basic_json_view<json>;
using json_view = basic_json_view<json, view_mode::read_only>;
```
This type is a [`basic_json_view`](basic_json_view/index.md) of a value of a [`json_document`](json_document.md).
@@ -3,7 +3,7 @@
<small>Defined in header `<nlohmann/json_view.hpp>`</small>
```cpp
using ordered_json_document = basic_json_document<ordered_json>;
using ordered_json_document = basic_json_document<ordered_json, view_mode::read_only>;
```
This type is a [`basic_json_document`](basic_json_document/index.md) of the [`ordered_json`](ordered_json.md)
+1 -1
View File
@@ -3,7 +3,7 @@
<small>Defined in header `<nlohmann/json_view.hpp>`</small>
```cpp
using ordered_json_view = basic_json_view<ordered_json>;
using ordered_json_view = basic_json_view<ordered_json, view_mode::read_only>;
```
This type is a [`basic_json_view`](basic_json_view/index.md) of a value of an
+1 -1
View File
@@ -30,7 +30,7 @@ The shortcuts name both modes: [`json_document`](json_document.md) and [`json_vi
## Notes
The mode is part of the view's type, and there is no conversion between the two modes: a read-only view reads a
The mode is a compile-time property of the document's and the view's type, not a setting of a call, and there is no conversion between the two modes: a read-only view reads a
container in place, while a view of an editable document follows the links that edits leave behind. A function that
accepts views therefore names the modes it accepts in its signature: