Repository navigation
Conversation
nlohmann
reviewed
Nov 13, 2026
nlohmann
left a comment
Owner
There was a problem hiding this comment.
Thanks! The changes look correct: I checked them against primitive_range_is_complete and json_ref(value_type&&) and ran the reproducers from #6114, which match the new text.
The only thing missing is the DCO sign-off. Could you amend the commit with git commit --amend -s --no-edit and force-push? Then this is good to merge from my side.
Optional nit: item 5 in basic_json.md is about the constructor, where the throwing case is basic_json(init, false, value_t::object) (json j = {std::move(a), 5} just creates an array). The json::object(...) example is still valid since it calls that constructor, so feel free to leave it.
Written by Claude Code.
…tion erase(first, last) on a primitive value only accepts [begin(); end()); the empty ranges [begin(); begin()) and [end(); end()) throw invalid_iterator.204, and the exceptions list now says "or" like the code does. The strong guarantee of json::object() and the initializer-list constructor does not cover values moved into the initializer list, which are moved before the constructor runs. Part of nlohmann#6114 Signed-off-by: 0xshubh4m <shubhamshakti137@gmail.com>
0xmyst3ry
force-pushed
the
docs-erase-empty-range-and-moved-elements
branch
from
November 13, 2026 18:35
1f5fc4d to
00a26cf
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes items 1 and 3 of #6114. Item 2 (the recorded assertion outputs in
features/assertions.mdandjson_assert.md) is not part of this PR: it needs the examples recompiled, or a decision to drop file and line numbers from the outputs.What
api/basic_json/erase.md, overload (2): the "empty range is a no-op" sentence now applies to arrays and objects only. For primitive values the range must be exactly[begin(); end()), and the empty ranges[begin(); begin())and[end(); end())throwinvalid_iterator.204. The 204 condition in the exceptions list now saysor, matching the code.api/basic_json/basic_json.md(item 5) andapi/basic_json/object.md: the strong guarantee does not cover values moved into the initializer list. They are moved when the list is created, before the constructor runs, and stay moved-from if it throws.Why
The pages promise behaviour the library does not have. The code is deliberate, so the pages are corrected rather than the code:
primitive_range_is_completeinjson.hppis used by botherase(first, last)and the range constructor, andinvalid_iterator.204already documents that only(begin(), end())is valid for primitives. For the second point,json_ref(value_type&&)moves the rvalue into its own storage when the braced list is built.How I checked
I read the code paths named above and compared the new wording against them. I did not compile or run the reproducers from the issue. Documentation only, so no test, amalgamation or coverage change.