Merge branch 'json-view/11-view-access' into json-view/12-view-values

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
Niels Lohmann
2026-09-29 22:42:18 +02:00
8 changed files with 66 additions and 21 deletions
+11 -3
View File
@@ -959,6 +959,14 @@ class builder
return w;
}
/// a compile-time option as a runtime condition: testing the template
/// argument directly makes a condition like `TrailingCommas && c == ']'`
/// constant when the option is off, which MSVC reports as C4127
static NLOHMANN_VIEW_ALWAYS_INLINE bool enabled(bool option) noexcept
{
return option;
}
/// The parse state and the parser proper. The cursor is a local object of
/// run() whose address never escapes (everything it calls out of line is a
/// member of the builder and gets the positions it needs), so that the
@@ -1088,7 +1096,7 @@ arr_next:
{
return false;
}
if (TrailingCommas && cur() == ']')
if (enabled(TrailingCommas) && cur() == ']')
{
++p;
goto close_container;
@@ -1155,7 +1163,7 @@ obj_next:
{
return false;
}
if (TrailingCommas && cur() == '}')
if (enabled(TrailingCommas) && cur() == '}')
{
++p;
goto close_container;
@@ -1297,7 +1305,7 @@ indent_done:
{
++p;
}
if (Comments && cur() == '/')
if (enabled(Comments) && cur() == '/')
{
const unsigned char* const q = cold.comment(p);
if (q == nullptr)