Spell out the move rationale at every handle_value(std::move) site

The comment explaining why the value is moved sat only on
json_sax_dom_parser::string(), and the callback parser's string() pointed
at it with "see json_sax_dom_parser::string()". That reference cannot be
searched for - the function is declared as `bool string(string_t& val)`
inside the class, so the qualified name appears nowhere - and the two
binary() overloads, which have always moved, carried no explanation at all.

Put the same comment on all four sites and name json_sax, which is
greppable, instead of a member that is not.

Comment-only; no generated code changes.

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
Niels Lohmann
2026-09-05 10:25:01 +02:00
parent 4edd54fcf5
commit c864df3341
2 changed files with 16 additions and 6 deletions
+8 -3
View File
@@ -222,14 +222,16 @@ class json_sax_dom_parser
bool string(string_t& val)
{
// the interface allows moving the value (see json_sax::string), which
// hands the lexer's buffer to the new value instead of copying it
// json_sax documents that the passed value may be moved from,
// so hand the buffer over instead of copying it
handle_value(std::move(val));
return true;
}
bool binary(binary_t& val)
{
// json_sax documents that the passed value may be moved from,
// so hand the buffer over instead of copying it
handle_value(std::move(val));
return true;
}
@@ -534,13 +536,16 @@ class json_sax_dom_callback_parser
bool string(string_t& val)
{
// see json_sax_dom_parser::string()
// json_sax documents that the passed value may be moved from,
// so hand the buffer over instead of copying it
handle_value(std::move(val));
return true;
}
bool binary(binary_t& val)
{
// json_sax documents that the passed value may be moved from,
// so hand the buffer over instead of copying it
handle_value(std::move(val));
return true;
}
+8 -3
View File
@@ -10804,14 +10804,16 @@ class json_sax_dom_parser
bool string(string_t& val)
{
// the interface allows moving the value (see json_sax::string), which
// hands the lexer's buffer to the new value instead of copying it
// json_sax documents that the passed value may be moved from,
// so hand the buffer over instead of copying it
handle_value(std::move(val));
return true;
}
bool binary(binary_t& val)
{
// json_sax documents that the passed value may be moved from,
// so hand the buffer over instead of copying it
handle_value(std::move(val));
return true;
}
@@ -11116,13 +11118,16 @@ class json_sax_dom_callback_parser
bool string(string_t& val)
{
// see json_sax_dom_parser::string()
// json_sax documents that the passed value may be moved from,
// so hand the buffer over instead of copying it
handle_value(std::move(val));
return true;
}
bool binary(binary_t& val)
{
// json_sax documents that the passed value may be moved from,
// so hand the buffer over instead of copying it
handle_value(std::move(val));
return true;
}