Merge develop; fix clang-tidy, cpplint and clang 3.5 findings in json_view

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
Niels Lohmann committed 2026-10-25 19:03:03 +01:00
commit 30e1adef93
422 files changed
+2662 -846

No files matched your search

+19 -5
View File
@@ -15773,9 +15773,17 @@ class json_sax_dom_parser : public json_sax_dom_error_state
/// so that a big object can find the keys it has in a hash table instead of
/// searching all of them
template<typename ObjectType, typename StringType>
using detect_indexable_keys = decltype(std::declval<ObjectType&>().emplace_new_key(std::declval<const StringType&>(), std::declval<typename ObjectType::mapped_type>()),
std::hash<StringType>()(std::declval<const StringType&>()));
static constexpr bool indexed_keys = is_detected<detect_indexable_keys, object_t, string_t>::value;
using detect_emplace_new_key = decltype(std::declval<ObjectType&>().emplace_new_key(std::declval<const StringType&>(), std::declval<typename ObjectType::mapped_type>()));
template<typename StringType>
using detect_hash = decltype(std::hash<StringType>()(std::declval<const StringType&>()));
// std::hash is only named once the object can hold the keys in a vector:
// VS 2015 static-asserts on std::hash of a type without one instead of
// reporting a substitution failure
template<typename ObjectType, typename StringType, bool = is_detected<detect_emplace_new_key, ObjectType, StringType>::value>
struct detect_indexable_keys : std::false_type {};
template<typename ObjectType, typename StringType>
struct detect_indexable_keys<ObjectType, StringType, true> : is_detected<detect_hash, StringType> {};
static constexpr bool indexed_keys = detect_indexable_keys<object_t, string_t>::value;
/// what a frame holds for objects that are kept in a vector: the key index
/// of an object with many keys, and for an object that is collected on the
@@ -15897,7 +15905,10 @@ class json_sax_dom_parser : public json_sax_dom_error_state
{
const std::size_t new_capacity = capacity * 2;
std::unique_ptr<frame[]> new_heap(new frame[new_capacity]); // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays)
std::copy(data, data + count, new_heap.get());
for (std::size_t i = 0; i < count; ++i)
{
new_heap[i] = data[i];
}
heap = std::move(new_heap);
data = heap.get();
capacity = new_capacity;
@@ -15915,7 +15926,10 @@ class json_sax_dom_parser : public json_sax_dom_error_state
{
if (other.heap == nullptr)
{
std::copy(other.local.begin(), other.local.begin() + static_cast<std::ptrdiff_t>(other.count), local.begin());
for (std::size_t i = 0; i < other.count; ++i)
{
local[i] = other.local[i];
}
data = local.data();
capacity = local_capacity;
}
+13 -6
View File
@@ -4766,7 +4766,7 @@ NLOHMANN_VIEW_ALWAYS_INLINE float_significand layout_decimal(const unsigned char
p += count + (frac_digits != 0 ? 1 : 0);
q = -static_cast<std::int64_t>(frac_digits);
}
else
else /* NOLINT(readability/braces) */
#endif
{
w = parse_upto19(p, int_digits, limit);
@@ -4879,7 +4879,7 @@ NLOHMANN_VIEW_ALWAYS_INLINE std::uint64_t coordinate_bits(std::int64_t q, std::u
}
const auto upperbit = static_cast<unsigned>(high >> 63u);
std::uint64_t mantissa = high >> (upperbit + 9);
std::uint64_t power2 = static_cast<std::uint64_t>(((217706 * q) >> 16) + 63 + static_cast<std::int64_t>(upperbit) - lz + 1023);
auto power2 = static_cast<std::uint64_t>(((217706 * q) >> 16) + 63 + static_cast<std::int64_t>(upperbit) - lz + 1023);
mantissa = (mantissa + (mantissa & 1u)) >> 1u;
const bool carry = mantissa >= (std::uint64_t{2} << 52u);
mantissa = carry ? (std::uint64_t{1} << 52u) : mantissa;
@@ -7681,7 +7681,7 @@ class view_serializer
NLOHMANN_VIEW_NOINLINE char* write_double_beside(char* w, const node* n, float_batch& batch)
{
// (an editable document's walk can skip nodes of the array)
const std::less<const node*> before;
const std::less<const node*> before{}; // NOLINT(modernize-use-transparent-functors) C++11 has no std::less<>
while (batch.next != batch.count && before(batch.at[batch.next], n))
{
++batch.next;
@@ -7717,7 +7717,7 @@ class view_serializer
*/
NLOHMANN_VIEW_NOINLINE bool convert_ahead(const node* n, float_batch& batch)
{
const std::less<const node*> before;
const std::less<const node*> before{}; // NOLINT(modernize-use-transparent-functors) C++11 has no std::less<>
const node* const last = m_doc.nodes + m_doc.node_count;
if (before(n, batch.scanned) || before(n, m_doc.nodes) || !before(n, last))
{
@@ -7760,7 +7760,14 @@ class view_serializer
const std::uint64_t w17 = (w * 10) + static_cast<std::uint64_t>(first[17] - '0');
const std::size_t i = batch.count++;
batch.at[i] = p;
digits[i] = p->len != sign + count + 1 ? 0 : (count == 17 ? w17 : w);
if (p->len != sign + count + 1)
{
digits[i] = 0;
}
else
{
digits[i] = count == 17 ? w17 : w;
}
exponent[i] = -static_cast<int>(frac_digits);
// (byte 0: the last digit, byte 1: the last two, bits 16-29: the last four)
std::uint32_t four = 0;
@@ -7860,7 +7867,7 @@ class view_serializer
{
return write_double_at(w, n); // (twelve or more trailing zeros)
}
const unsigned zeros = last_zeros != 0 ? static_cast<unsigned>(count_leading_zeros(last_zeros)) / 8 - 4
const unsigned zeros = last_zeros != 0 ? (static_cast<unsigned>(count_leading_zeros(last_zeros)) / 8) - 4
: 4 + (static_cast<unsigned>(count_leading_zeros(before_zeros)) / 8);
const unsigned frac_digits = n.extra >> 8u;
return end - (zeros < frac_digits ? zeros : frac_digits - 1);