Fix the clang-tidy findings in the diff and JSON pointer code

- diff_target_values holds its inline values in a std::array (a type
  with an empty user-provided constructor, as the serializer's buffers,
  so that -Weffc++ is met and they stay uninitialized) and declares its
  move members as deleted
- auto for an iterator and a cast, and parentheses around a %

json::diff() instructions are unchanged within noise (Apple clang,
twitter and citm_catalog).

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
Niels Lohmann committed 2026-10-22 17:45:18 +02:00
1 parent 892a2dd957
commit d96ec00d53
3 files changed
+38 -12

No files matched your search

+2 -2
View File
@@ -874,7 +874,7 @@ class json_pointer
// an index of up to 18 digits without a leading zero fits into size_type
// (9 digits for a 32-bit size_type); everything else is left to json_pointer
constexpr std::size_t max_digits = sizeof(typename BasicJsonType::size_type) >= 8 ? 18 : 9;
const std::size_t digits = static_cast<std::size_t>(end - begin);
const auto digits = static_cast<std::size_t>(end - begin);
if (JSON_HEDLEY_UNLIKELY(digits == 0 || digits > max_digits || (digits > 1 && *begin == '0')))
{
return nullptr;
@@ -1575,7 +1575,7 @@ class json_pointer
std::size_t rest = i;
do
{
digits[--pos] = static_cast<char>('0' + rest % 10);
digits[--pos] = static_cast<char>('0' + (rest % 10));
rest /= 10;
}
while (rest != 0);