Copy the tokens of json_pointer::to_string() with std::copy

clang-tidy (bugprone-not-null-terminated-result) took the memcpy into
the result string for a C string missing its terminator. std::copy is
the same memmove; to_string() instructions are unchanged (Apple clang).

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
Niels Lohmann committed 2026-10-22 13:32:19 +02:00
1 parent eb2a092d70
commit a9ed3feca3
2 files changed
+4 -6

No files matched your search

+2 -3
View File
@@ -8,7 +8,7 @@
#pragma once
#include <algorithm> // all_of
#include <algorithm> // all_of, copy
#include <array> // array
#include <cctype> // isdigit
#include <cerrno> // errno, ERANGE
@@ -104,8 +104,7 @@ class json_pointer
for (const auto& reference_token : reference_tokens)
{
*out++ = '/';
std::memcpy(out, reference_token.data(), reference_token.size());
out += reference_token.size();
out = std::copy(reference_token.data(), reference_token.data() + reference_token.size(), out);
}
}
return result;