Annotate intentional patterns in unit-json_view.cpp for clang-tidy

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
Niels Lohmann committed 2026-10-10 00:19:40 +02:00
1 parent 38e34eb960
commit 81ead20445
1 file changed
+3 -3
+3 -3
View File
@@ -56,7 +56,7 @@ struct oversized_input
using value_type = char; using value_type = char;
std::size_t claimed; std::size_t claimed;
const char* data() const const char* data() const // NOLINT(readability-convert-member-functions-to-static): container interface
{ {
return "[1]"; return "[1]";
} }
@@ -353,10 +353,10 @@ TEST_CASE("json_view")
CHECK(json_document::parse(std::vector<char>(text.begin(), text.end())).owns_source()); CHECK(json_document::parse(std::vector<char>(text.begin(), text.end())).owns_source());
// a const rvalue cannot be moved from, and is not borrowed (it may be a // a const rvalue cannot be moved from, and is not borrowed (it may be a
// temporary): it is copied, as is a const rvalue of any container // temporary): it is copied, as is a const rvalue of any container
const std::string const_text = text; const std::string const_text = text; // NOLINT(performance-unnecessary-copy-initialization)
const json_document from_const_rvalue = json_document::parse(std::move(const_text)); // NOLINT(performance-move-const-arg,hicpp-move-const-arg) const json_document from_const_rvalue = json_document::parse(std::move(const_text)); // NOLINT(performance-move-const-arg,hicpp-move-const-arg)
CHECK(from_const_rvalue.owns_source()); CHECK(from_const_rvalue.owns_source());
CHECK(from_const_rvalue.source().data() != const_text.data()); CHECK(from_const_rvalue.source().data() != const_text.data()); // NOLINT(bugprone-use-after-move,hicpp-invalid-access-moved): const, not moved from
CHECK(from_const_rvalue.root().materialize() == expected); CHECK(from_const_rvalue.root().materialize() == expected);
json_document read_const_rvalue; json_document read_const_rvalue;
read_const_rvalue.read(std::move(const_text)); // NOLINT(performance-move-const-arg,hicpp-move-const-arg) read_const_rvalue.read(std::move(const_text)); // NOLINT(performance-move-const-arg,hicpp-move-const-arg)