mirror of
https://github.com/nlohmann/json.git
synced 2026-10-24 06:48:55 +00:00
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:
2 files changed
+4
-6
No files matched your search
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <algorithm> // all_of
|
#include <algorithm> // all_of, copy
|
||||||
#include <array> // array
|
#include <array> // array
|
||||||
#include <cctype> // isdigit
|
#include <cctype> // isdigit
|
||||||
#include <cerrno> // errno, ERANGE
|
#include <cerrno> // errno, ERANGE
|
||||||
@@ -104,8 +104,7 @@ class json_pointer
|
|||||||
for (const auto& reference_token : reference_tokens)
|
for (const auto& reference_token : reference_tokens)
|
||||||
{
|
{
|
||||||
*out++ = '/';
|
*out++ = '/';
|
||||||
std::memcpy(out, reference_token.data(), reference_token.size());
|
out = std::copy(reference_token.data(), reference_token.data() + reference_token.size(), out);
|
||||||
out += reference_token.size();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
Generated
+2
-3
@@ -22350,7 +22350,7 @@ NLOHMANN_JSON_NAMESPACE_END
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include <algorithm> // all_of
|
#include <algorithm> // all_of, copy
|
||||||
#include <array> // array
|
#include <array> // array
|
||||||
#include <cctype> // isdigit
|
#include <cctype> // isdigit
|
||||||
#include <cerrno> // errno, ERANGE
|
#include <cerrno> // errno, ERANGE
|
||||||
@@ -22454,8 +22454,7 @@ class json_pointer
|
|||||||
for (const auto& reference_token : reference_tokens)
|
for (const auto& reference_token : reference_tokens)
|
||||||
{
|
{
|
||||||
*out++ = '/';
|
*out++ = '/';
|
||||||
std::memcpy(out, reference_token.data(), reference_token.size());
|
out = std::copy(reference_token.data(), reference_token.data() + reference_token.size(), out);
|
||||||
out += reference_token.size();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
Reference in new issue
Block a user