From 8b3d2399a487a3d5c52a09d258d9df83e7a6066e Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Mon, 22 Jun 2020 22:32:21 +0200 Subject: [PATCH] :rotating_light: remove warnings --- .clang-tidy | 27 +- .../nlohmann/detail/input/binary_reader.hpp | 166 ++++++------ .../nlohmann/detail/input/input_adapters.hpp | 4 +- include/nlohmann/detail/input/json_sax.hpp | 20 +- include/nlohmann/detail/input/lexer.hpp | 2 +- .../detail/iterators/internal_iterator.hpp | 2 - include/nlohmann/detail/json_ref.hpp | 19 +- .../nlohmann/detail/output/binary_writer.hpp | 26 +- include/nlohmann/detail/output/serializer.hpp | 8 +- single_include/nlohmann/json.hpp | 247 +++++++++--------- 10 files changed, 250 insertions(+), 271 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index feee8194..046d84f8 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -1,23 +1,20 @@ -Checks: '-*, - bugprone-*, - cert-*, - clang-analyzer-*, - google-*, - -google-runtime-references, +Checks: '*, + -cppcoreguidelines-avoid-goto, + -cppcoreguidelines-avoid-magic-numbers, + -cppcoreguidelines-macro-usage, + -fuchsia-default-arguments-calls, + -fuchsia-default-arguments-declarations, + -fuchsia-overloaded-operator, -google-explicit-constructor, - hicpp-*, + -google-runtime-references, + -hicpp-avoid-goto, + -hicpp-explicit-conversions, -hicpp-no-array-decay, -hicpp-uppercase-literal-suffix, - -hicpp-explicit-conversions, - misc-*, - -misc-non-private-member-variables-in-classes, - llvm-*, -llvm-header-guard, - modernize-*, + -llvm-include-order, + -misc-non-private-member-variables-in-classes, -modernize-use-trailing-return-type, - performance-*, - portability-*, - readability-*, -readability-magic-numbers, -readability-uppercase-literal-suffix' diff --git a/include/nlohmann/detail/input/binary_reader.hpp b/include/nlohmann/detail/input/binary_reader.hpp index 93667e8f..a27a1538 100644 --- a/include/nlohmann/detail/input/binary_reader.hpp +++ b/include/nlohmann/detail/input/binary_reader.hpp @@ -145,7 +145,7 @@ class binary_reader */ bool parse_bson_internal() { - std::int32_t document_size; + std::int32_t document_size{}; get_number(input_format_t::bson, document_size); if (JSON_HEDLEY_UNLIKELY(not sax->start_object(std::size_t(-1)))) @@ -184,8 +184,6 @@ class binary_reader } *out++ = static_cast(current); } - - return true; } /*! @@ -230,7 +228,7 @@ class binary_reader } // All BSON binary values have a subtype - std::uint8_t subtype; + std::uint8_t subtype{}; get_number(input_format_t::bson, subtype); result.set_subtype(subtype); @@ -254,13 +252,13 @@ class binary_reader { case 0x01: // double { - double number; + double number{}; return get_number(input_format_t::bson, number) and sax->number_float(static_cast(number), ""); } case 0x02: // string { - std::int32_t len; + std::int32_t len{}; string_t value; return get_number(input_format_t::bson, len) and get_bson_string(len, value) and sax->string(value); } @@ -277,7 +275,7 @@ class binary_reader case 0x05: // binary { - std::int32_t len; + std::int32_t len{}; binary_t value; return get_number(input_format_t::bson, len) and get_bson_binary(len, value) and sax->binary(value); } @@ -294,13 +292,13 @@ class binary_reader case 0x10: // int32 { - std::int32_t value; + std::int32_t value{}; return get_number(input_format_t::bson, value) and sax->number_integer(value); } case 0x12: // int64 { - std::int64_t value; + std::int64_t value{}; return get_number(input_format_t::bson, value) and sax->number_integer(value); } @@ -365,7 +363,7 @@ class binary_reader */ bool parse_bson_array() { - std::int32_t document_size; + std::int32_t document_size{}; get_number(input_format_t::bson, document_size); if (JSON_HEDLEY_UNLIKELY(not sax->start_array(std::size_t(-1)))) @@ -429,25 +427,25 @@ class binary_reader case 0x18: // Unsigned integer (one-byte uint8_t follows) { - std::uint8_t number; + std::uint8_t number{}; return get_number(input_format_t::cbor, number) and sax->number_unsigned(number); } case 0x19: // Unsigned integer (two-byte uint16_t follows) { - std::uint16_t number; + std::uint16_t number{}; return get_number(input_format_t::cbor, number) and sax->number_unsigned(number); } case 0x1A: // Unsigned integer (four-byte uint32_t follows) { - std::uint32_t number; + std::uint32_t number{}; return get_number(input_format_t::cbor, number) and sax->number_unsigned(number); } case 0x1B: // Unsigned integer (eight-byte uint64_t follows) { - std::uint64_t number; + std::uint64_t number{}; return get_number(input_format_t::cbor, number) and sax->number_unsigned(number); } @@ -480,25 +478,25 @@ class binary_reader case 0x38: // Negative integer (one-byte uint8_t follows) { - std::uint8_t number; + std::uint8_t number{}; return get_number(input_format_t::cbor, number) and sax->number_integer(static_cast(-1) - number); } case 0x39: // Negative integer -1-n (two-byte uint16_t follows) { - std::uint16_t number; + std::uint16_t number{}; return get_number(input_format_t::cbor, number) and sax->number_integer(static_cast(-1) - number); } case 0x3A: // Negative integer -1-n (four-byte uint32_t follows) { - std::uint32_t number; + std::uint32_t number{}; return get_number(input_format_t::cbor, number) and sax->number_integer(static_cast(-1) - number); } case 0x3B: // Negative integer -1-n (eight-byte uint64_t follows) { - std::uint64_t number; + std::uint64_t number{}; return get_number(input_format_t::cbor, number) and sax->number_integer(static_cast(-1) - static_cast(number)); } @@ -602,25 +600,25 @@ class binary_reader case 0x98: // array (one-byte uint8_t for n follows) { - std::uint8_t len; + std::uint8_t len{}; return get_number(input_format_t::cbor, len) and get_cbor_array(static_cast(len)); } case 0x99: // array (two-byte uint16_t for n follow) { - std::uint16_t len; + std::uint16_t len{}; return get_number(input_format_t::cbor, len) and get_cbor_array(static_cast(len)); } case 0x9A: // array (four-byte uint32_t for n follow) { - std::uint32_t len; + std::uint32_t len{}; return get_number(input_format_t::cbor, len) and get_cbor_array(static_cast(len)); } case 0x9B: // array (eight-byte uint64_t for n follow) { - std::uint64_t len; + std::uint64_t len{}; return get_number(input_format_t::cbor, len) and get_cbor_array(static_cast(len)); } @@ -656,25 +654,25 @@ class binary_reader case 0xB8: // map (one-byte uint8_t for n follows) { - std::uint8_t len; + std::uint8_t len{}; return get_number(input_format_t::cbor, len) and get_cbor_object(static_cast(len)); } case 0xB9: // map (two-byte uint16_t for n follow) { - std::uint16_t len; + std::uint16_t len{}; return get_number(input_format_t::cbor, len) and get_cbor_object(static_cast(len)); } case 0xBA: // map (four-byte uint32_t for n follow) { - std::uint32_t len; + std::uint32_t len{}; return get_number(input_format_t::cbor, len) and get_cbor_object(static_cast(len)); } case 0xBB: // map (eight-byte uint64_t for n follow) { - std::uint64_t len; + std::uint64_t len{}; return get_number(input_format_t::cbor, len) and get_cbor_object(static_cast(len)); } @@ -740,13 +738,13 @@ class binary_reader case 0xFA: // Single-Precision Float (four-byte IEEE 754) { - float number; + float number{}; return get_number(input_format_t::cbor, number) and sax->number_float(static_cast(number), ""); } case 0xFB: // Double-Precision Float (eight-byte IEEE 754) { - double number; + double number{}; return get_number(input_format_t::cbor, number) and sax->number_float(static_cast(number), ""); } @@ -809,25 +807,25 @@ class binary_reader case 0x78: // UTF-8 string (one-byte uint8_t for n follows) { - std::uint8_t len; + std::uint8_t len{}; return get_number(input_format_t::cbor, len) and get_string(input_format_t::cbor, len, result); } case 0x79: // UTF-8 string (two-byte uint16_t for n follow) { - std::uint16_t len; + std::uint16_t len{}; return get_number(input_format_t::cbor, len) and get_string(input_format_t::cbor, len, result); } case 0x7A: // UTF-8 string (four-byte uint32_t for n follow) { - std::uint32_t len; + std::uint32_t len{}; return get_number(input_format_t::cbor, len) and get_string(input_format_t::cbor, len, result); } case 0x7B: // UTF-8 string (eight-byte uint64_t for n follow) { - std::uint64_t len; + std::uint64_t len{}; return get_number(input_format_t::cbor, len) and get_string(input_format_t::cbor, len, result); } @@ -904,28 +902,28 @@ class binary_reader case 0x58: // Binary data (one-byte uint8_t for n follows) { - std::uint8_t len; + std::uint8_t len{}; return get_number(input_format_t::cbor, len) and get_binary(input_format_t::cbor, len, result); } case 0x59: // Binary data (two-byte uint16_t for n follow) { - std::uint16_t len; + std::uint16_t len{}; return get_number(input_format_t::cbor, len) and get_binary(input_format_t::cbor, len, result); } case 0x5A: // Binary data (four-byte uint32_t for n follow) { - std::uint32_t len; + std::uint32_t len{}; return get_number(input_format_t::cbor, len) and get_binary(input_format_t::cbor, len, result); } case 0x5B: // Binary data (eight-byte uint64_t for n follow) { - std::uint64_t len; + std::uint64_t len{}; return get_number(input_format_t::cbor, len) and get_binary(input_format_t::cbor, len, result); } @@ -1290,85 +1288,85 @@ class binary_reader case 0xCA: // float 32 { - float number; + float number{}; return get_number(input_format_t::msgpack, number) and sax->number_float(static_cast(number), ""); } case 0xCB: // float 64 { - double number; + double number{}; return get_number(input_format_t::msgpack, number) and sax->number_float(static_cast(number), ""); } case 0xCC: // uint 8 { - std::uint8_t number; + std::uint8_t number{}; return get_number(input_format_t::msgpack, number) and sax->number_unsigned(number); } case 0xCD: // uint 16 { - std::uint16_t number; + std::uint16_t number{}; return get_number(input_format_t::msgpack, number) and sax->number_unsigned(number); } case 0xCE: // uint 32 { - std::uint32_t number; + std::uint32_t number{}; return get_number(input_format_t::msgpack, number) and sax->number_unsigned(number); } case 0xCF: // uint 64 { - std::uint64_t number; + std::uint64_t number{}; return get_number(input_format_t::msgpack, number) and sax->number_unsigned(number); } case 0xD0: // int 8 { - std::int8_t number; + std::int8_t number{}; return get_number(input_format_t::msgpack, number) and sax->number_integer(number); } case 0xD1: // int 16 { - std::int16_t number; + std::int16_t number{}; return get_number(input_format_t::msgpack, number) and sax->number_integer(number); } case 0xD2: // int 32 { - std::int32_t number; + std::int32_t number{}; return get_number(input_format_t::msgpack, number) and sax->number_integer(number); } case 0xD3: // int 64 { - std::int64_t number; + std::int64_t number{}; return get_number(input_format_t::msgpack, number) and sax->number_integer(number); } case 0xDC: // array 16 { - std::uint16_t len; + std::uint16_t len{}; return get_number(input_format_t::msgpack, len) and get_msgpack_array(static_cast(len)); } case 0xDD: // array 32 { - std::uint32_t len; + std::uint32_t len{}; return get_number(input_format_t::msgpack, len) and get_msgpack_array(static_cast(len)); } case 0xDE: // map 16 { - std::uint16_t len; + std::uint16_t len{}; return get_number(input_format_t::msgpack, len) and get_msgpack_object(static_cast(len)); } case 0xDF: // map 32 { - std::uint32_t len; + std::uint32_t len{}; return get_number(input_format_t::msgpack, len) and get_msgpack_object(static_cast(len)); } @@ -1473,19 +1471,19 @@ class binary_reader case 0xD9: // str 8 { - std::uint8_t len; + std::uint8_t len{}; return get_number(input_format_t::msgpack, len) and get_string(input_format_t::msgpack, len, result); } case 0xDA: // str 16 { - std::uint16_t len; + std::uint16_t len{}; return get_number(input_format_t::msgpack, len) and get_string(input_format_t::msgpack, len, result); } case 0xDB: // str 32 { - std::uint32_t len; + std::uint32_t len{}; return get_number(input_format_t::msgpack, len) and get_string(input_format_t::msgpack, len, result); } @@ -1520,29 +1518,29 @@ class binary_reader { case 0xC4: // bin 8 { - std::uint8_t len; + std::uint8_t len{}; return get_number(input_format_t::msgpack, len) and get_binary(input_format_t::msgpack, len, result); } case 0xC5: // bin 16 { - std::uint16_t len; + std::uint16_t len{}; return get_number(input_format_t::msgpack, len) and get_binary(input_format_t::msgpack, len, result); } case 0xC6: // bin 32 { - std::uint32_t len; + std::uint32_t len{}; return get_number(input_format_t::msgpack, len) and get_binary(input_format_t::msgpack, len, result); } case 0xC7: // ext 8 { - std::uint8_t len; - std::int8_t subtype; + std::uint8_t len{}; + std::int8_t subtype{}; return get_number(input_format_t::msgpack, len) and get_number(input_format_t::msgpack, subtype) and get_binary(input_format_t::msgpack, len, result) and @@ -1551,8 +1549,8 @@ class binary_reader case 0xC8: // ext 16 { - std::uint16_t len; - std::int8_t subtype; + std::uint16_t len{}; + std::int8_t subtype{}; return get_number(input_format_t::msgpack, len) and get_number(input_format_t::msgpack, subtype) and get_binary(input_format_t::msgpack, len, result) and @@ -1561,8 +1559,8 @@ class binary_reader case 0xC9: // ext 32 { - std::uint32_t len; - std::int8_t subtype; + std::uint32_t len{}; + std::int8_t subtype{}; return get_number(input_format_t::msgpack, len) and get_number(input_format_t::msgpack, subtype) and get_binary(input_format_t::msgpack, len, result) and @@ -1571,7 +1569,7 @@ class binary_reader case 0xD4: // fixext 1 { - std::int8_t subtype; + std::int8_t subtype{}; return get_number(input_format_t::msgpack, subtype) and get_binary(input_format_t::msgpack, 1, result) and assign_and_return_true(subtype); @@ -1579,7 +1577,7 @@ class binary_reader case 0xD5: // fixext 2 { - std::int8_t subtype; + std::int8_t subtype{}; return get_number(input_format_t::msgpack, subtype) and get_binary(input_format_t::msgpack, 2, result) and assign_and_return_true(subtype); @@ -1587,7 +1585,7 @@ class binary_reader case 0xD6: // fixext 4 { - std::int8_t subtype; + std::int8_t subtype{}; return get_number(input_format_t::msgpack, subtype) and get_binary(input_format_t::msgpack, 4, result) and assign_and_return_true(subtype); @@ -1595,7 +1593,7 @@ class binary_reader case 0xD7: // fixext 8 { - std::int8_t subtype; + std::int8_t subtype{}; return get_number(input_format_t::msgpack, subtype) and get_binary(input_format_t::msgpack, 8, result) and assign_and_return_true(subtype); @@ -1603,7 +1601,7 @@ class binary_reader case 0xD8: // fixext 16 { - std::int8_t subtype; + std::int8_t subtype{}; return get_number(input_format_t::msgpack, subtype) and get_binary(input_format_t::msgpack, 16, result) and assign_and_return_true(subtype); @@ -1712,31 +1710,31 @@ class binary_reader { case 'U': { - std::uint8_t len; + std::uint8_t len{}; return get_number(input_format_t::ubjson, len) and get_string(input_format_t::ubjson, len, result); } case 'i': { - std::int8_t len; + std::int8_t len{}; return get_number(input_format_t::ubjson, len) and get_string(input_format_t::ubjson, len, result); } case 'I': { - std::int16_t len; + std::int16_t len{}; return get_number(input_format_t::ubjson, len) and get_string(input_format_t::ubjson, len, result); } case 'l': { - std::int32_t len; + std::int32_t len{}; return get_number(input_format_t::ubjson, len) and get_string(input_format_t::ubjson, len, result); } case 'L': { - std::int64_t len; + std::int64_t len{}; return get_number(input_format_t::ubjson, len) and get_string(input_format_t::ubjson, len, result); } @@ -1756,7 +1754,7 @@ class binary_reader { case 'U': { - std::uint8_t number; + std::uint8_t number{}; if (JSON_HEDLEY_UNLIKELY(not get_number(input_format_t::ubjson, number))) { return false; @@ -1767,7 +1765,7 @@ class binary_reader case 'i': { - std::int8_t number; + std::int8_t number{}; if (JSON_HEDLEY_UNLIKELY(not get_number(input_format_t::ubjson, number))) { return false; @@ -1778,7 +1776,7 @@ class binary_reader case 'I': { - std::int16_t number; + std::int16_t number{}; if (JSON_HEDLEY_UNLIKELY(not get_number(input_format_t::ubjson, number))) { return false; @@ -1789,7 +1787,7 @@ class binary_reader case 'l': { - std::int32_t number; + std::int32_t number{}; if (JSON_HEDLEY_UNLIKELY(not get_number(input_format_t::ubjson, number))) { return false; @@ -1800,7 +1798,7 @@ class binary_reader case 'L': { - std::int64_t number; + std::int64_t number{}; if (JSON_HEDLEY_UNLIKELY(not get_number(input_format_t::ubjson, number))) { return false; @@ -1885,43 +1883,43 @@ class binary_reader case 'U': { - std::uint8_t number; + std::uint8_t number{}; return get_number(input_format_t::ubjson, number) and sax->number_unsigned(number); } case 'i': { - std::int8_t number; + std::int8_t number{}; return get_number(input_format_t::ubjson, number) and sax->number_integer(number); } case 'I': { - std::int16_t number; + std::int16_t number{}; return get_number(input_format_t::ubjson, number) and sax->number_integer(number); } case 'l': { - std::int32_t number; + std::int32_t number{}; return get_number(input_format_t::ubjson, number) and sax->number_integer(number); } case 'L': { - std::int64_t number; + std::int64_t number{}; return get_number(input_format_t::ubjson, number) and sax->number_integer(number); } case 'd': { - float number; + float number{}; return get_number(input_format_t::ubjson, number) and sax->number_float(static_cast(number), ""); } case 'D': { - double number; + double number{}; return get_number(input_format_t::ubjson, number) and sax->number_float(static_cast(number), ""); } diff --git a/include/nlohmann/detail/input/input_adapters.hpp b/include/nlohmann/detail/input/input_adapters.hpp index ed9db0f6..47ea4a5b 100644 --- a/include/nlohmann/detail/input/input_adapters.hpp +++ b/include/nlohmann/detail/input/input_adapters.hpp @@ -76,7 +76,7 @@ class input_stream_adapter { // clear stream flags; we use underlying streambuf I/O, do not // maintain ifstream flags, except eof - if (is) + if (is != nullptr) { is->clear(is->rdstate() & std::ios::eofbit); } @@ -411,7 +411,7 @@ template < typename CharT, contiguous_bytes_input_adapter input_adapter(CharT b) { auto length = std::strlen(reinterpret_cast(b)); - auto ptr = reinterpret_cast(b); + const auto* ptr = reinterpret_cast(b); return input_adapter(ptr, ptr + length); } diff --git a/include/nlohmann/detail/input/json_sax.hpp b/include/nlohmann/detail/input/json_sax.hpp index 66b08bff..c7c1db81 100644 --- a/include/nlohmann/detail/input/json_sax.hpp +++ b/include/nlohmann/detail/input/json_sax.hpp @@ -269,16 +269,16 @@ class json_sax_dom_parser switch ((ex.id / 100) % 100) { case 1: - JSON_THROW(*static_cast(&ex)); + JSON_THROW(*dynamic_cast(&ex)); case 4: - JSON_THROW(*static_cast(&ex)); + JSON_THROW(*dynamic_cast(&ex)); // LCOV_EXCL_START case 2: - JSON_THROW(*static_cast(&ex)); + JSON_THROW(*dynamic_cast(&ex)); case 3: - JSON_THROW(*static_cast(&ex)); + JSON_THROW(*dynamic_cast(&ex)); case 5: - JSON_THROW(*static_cast(&ex)); + JSON_THROW(*dynamic_cast(&ex)); default: assert(false); // LCOV_EXCL_STOP @@ -523,16 +523,16 @@ class json_sax_dom_callback_parser switch ((ex.id / 100) % 100) { case 1: - JSON_THROW(*static_cast(&ex)); + JSON_THROW(*dynamic_cast(&ex)); case 4: - JSON_THROW(*static_cast(&ex)); + JSON_THROW(*dynamic_cast(&ex)); // LCOV_EXCL_START case 2: - JSON_THROW(*static_cast(&ex)); + JSON_THROW(*dynamic_cast(&ex)); case 3: - JSON_THROW(*static_cast(&ex)); + JSON_THROW(*dynamic_cast(&ex)); case 5: - JSON_THROW(*static_cast(&ex)); + JSON_THROW(*dynamic_cast(&ex)); default: assert(false); // LCOV_EXCL_STOP diff --git a/include/nlohmann/detail/input/lexer.hpp b/include/nlohmann/detail/input/lexer.hpp index 0ff0c736..6d188e47 100644 --- a/include/nlohmann/detail/input/lexer.hpp +++ b/include/nlohmann/detail/input/lexer.hpp @@ -131,7 +131,7 @@ class lexer : public lexer_base JSON_HEDLEY_PURE static char get_decimal_point() noexcept { - const auto loc = localeconv(); + const auto* loc = localeconv(); assert(loc != nullptr); return (loc->decimal_point == nullptr) ? '.' : *(loc->decimal_point); } diff --git a/include/nlohmann/detail/iterators/internal_iterator.hpp b/include/nlohmann/detail/iterators/internal_iterator.hpp index 742df483..2c81f723 100644 --- a/include/nlohmann/detail/iterators/internal_iterator.hpp +++ b/include/nlohmann/detail/iterators/internal_iterator.hpp @@ -18,8 +18,6 @@ template struct internal_iterator typename BasicJsonType::object_t::iterator object_iterator {}; /// iterator for JSON arrays typename BasicJsonType::array_t::iterator array_iterator {}; - /// iterator for JSON binary arrays - typename BasicJsonType::binary_t::container_type::iterator binary_iterator {}; /// generic iterator for all other types primitive_iterator_t primitive_iterator {}; }; diff --git a/include/nlohmann/detail/json_ref.hpp b/include/nlohmann/detail/json_ref.hpp index c8dec733..c9bf6cb2 100644 --- a/include/nlohmann/detail/json_ref.hpp +++ b/include/nlohmann/detail/json_ref.hpp @@ -16,23 +16,30 @@ class json_ref using value_type = BasicJsonType; json_ref(value_type&& value) - : owned_value(std::move(value)), value_ref(&owned_value), is_rvalue(true) + : owned_value(std::move(value)) + , value_ref(&owned_value) + , is_rvalue(true) {} json_ref(const value_type& value) - : value_ref(const_cast(&value)), is_rvalue(false) + : value_ref(const_cast(&value)) + , is_rvalue(false) {} json_ref(std::initializer_list init) - : owned_value(init), value_ref(&owned_value), is_rvalue(true) + : owned_value(init) + , value_ref(&owned_value) + , is_rvalue(true) {} template < class... Args, enable_if_t::value, int> = 0 > json_ref(Args && ... args) - : owned_value(std::forward(args)...), value_ref(&owned_value), - is_rvalue(true) {} + : owned_value(std::forward(args)...) + , value_ref(&owned_value) + , is_rvalue(true) + {} // class should be movable only json_ref(json_ref&&) = default; @@ -63,7 +70,7 @@ class json_ref private: mutable value_type owned_value = nullptr; value_type* value_ref = nullptr; - const bool is_rvalue; + const bool is_rvalue = true; }; } // namespace detail } // namespace nlohmann diff --git a/include/nlohmann/detail/output/binary_writer.hpp b/include/nlohmann/detail/output/binary_writer.hpp index 7289da3d..3bac0227 100644 --- a/include/nlohmann/detail/output/binary_writer.hpp +++ b/include/nlohmann/detail/output/binary_writer.hpp @@ -573,7 +573,7 @@ class binary_writer const auto N = j.m_value.binary->size(); if (N <= (std::numeric_limits::max)()) { - std::uint8_t output_type; + std::uint8_t output_type{}; bool fixed = true; if (use_ext) { @@ -615,30 +615,18 @@ class binary_writer } else if (N <= (std::numeric_limits::max)()) { - std::uint8_t output_type; - if (use_ext) - { - output_type = 0xC8; // ext 16 - } - else - { - output_type = 0xC5; // bin 16 - } + std::uint8_t output_type = use_ext + ? 0xC8 // ext 16 + : 0xC5; // bin 16 oa->write_character(to_char_type(output_type)); write_number(static_cast(N)); } else if (N <= (std::numeric_limits::max)()) { - std::uint8_t output_type; - if (use_ext) - { - output_type = 0xC9; // ext 32 - } - else - { - output_type = 0xC6; // bin 32 - } + std::uint8_t output_type = use_ext + ? 0xC9 // ext 32 + : 0xC6; // bin 32 oa->write_character(to_char_type(output_type)); write_number(static_cast(N)); diff --git a/include/nlohmann/detail/output/serializer.hpp b/include/nlohmann/detail/output/serializer.hpp index e8f31fd8..d86113b3 100644 --- a/include/nlohmann/detail/output/serializer.hpp +++ b/include/nlohmann/detail/output/serializer.hpp @@ -9,7 +9,7 @@ #include // uint8_t #include // snprintf #include // numeric_limits -#include // string +#include // string, char_traits #include // is_same #include // move @@ -59,8 +59,8 @@ class serializer error_handler_t error_handler_ = error_handler_t::strict) : o(std::move(s)) , loc(std::localeconv()) - , thousands_sep(loc->thousands_sep == nullptr ? '\0' : * (loc->thousands_sep)) - , decimal_point(loc->decimal_point == nullptr ? '\0' : * (loc->decimal_point)) + , thousands_sep(loc->thousands_sep == nullptr ? '\0' : std::char_traits::to_char_type(* (loc->thousands_sep))) + , decimal_point(loc->decimal_point == nullptr ? '\0' : std::char_traits::to_char_type(* (loc->decimal_point))) , indent_char(ichar) , indent_string(512, indent_char) , error_handler(error_handler_) @@ -701,7 +701,7 @@ class serializer } // use a pointer to fill the buffer - auto buffer_ptr = number_buffer.begin(); + auto* buffer_ptr = number_buffer.begin(); const bool is_negative = std::is_same::value and not(x >= 0); // see issue #755 number_unsigned_t abs_value; diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index e2aea103..d0e01c86 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -4502,7 +4502,7 @@ class input_stream_adapter { // clear stream flags; we use underlying streambuf I/O, do not // maintain ifstream flags, except eof - if (is) + if (is != nullptr) { is->clear(is->rdstate() & std::ios::eofbit); } @@ -4837,7 +4837,7 @@ template < typename CharT, contiguous_bytes_input_adapter input_adapter(CharT b) { auto length = std::strlen(reinterpret_cast(b)); - auto ptr = reinterpret_cast(b); + const auto* ptr = reinterpret_cast(b); return input_adapter(ptr, ptr + length); } @@ -5154,16 +5154,16 @@ class json_sax_dom_parser switch ((ex.id / 100) % 100) { case 1: - JSON_THROW(*static_cast(&ex)); + JSON_THROW(*dynamic_cast(&ex)); case 4: - JSON_THROW(*static_cast(&ex)); + JSON_THROW(*dynamic_cast(&ex)); // LCOV_EXCL_START case 2: - JSON_THROW(*static_cast(&ex)); + JSON_THROW(*dynamic_cast(&ex)); case 3: - JSON_THROW(*static_cast(&ex)); + JSON_THROW(*dynamic_cast(&ex)); case 5: - JSON_THROW(*static_cast(&ex)); + JSON_THROW(*dynamic_cast(&ex)); default: assert(false); // LCOV_EXCL_STOP @@ -5408,16 +5408,16 @@ class json_sax_dom_callback_parser switch ((ex.id / 100) % 100) { case 1: - JSON_THROW(*static_cast(&ex)); + JSON_THROW(*dynamic_cast(&ex)); case 4: - JSON_THROW(*static_cast(&ex)); + JSON_THROW(*dynamic_cast(&ex)); // LCOV_EXCL_START case 2: - JSON_THROW(*static_cast(&ex)); + JSON_THROW(*dynamic_cast(&ex)); case 3: - JSON_THROW(*static_cast(&ex)); + JSON_THROW(*dynamic_cast(&ex)); case 5: - JSON_THROW(*static_cast(&ex)); + JSON_THROW(*dynamic_cast(&ex)); default: assert(false); // LCOV_EXCL_STOP @@ -5886,7 +5886,7 @@ class binary_reader */ bool parse_bson_internal() { - std::int32_t document_size; + std::int32_t document_size{}; get_number(input_format_t::bson, document_size); if (JSON_HEDLEY_UNLIKELY(not sax->start_object(std::size_t(-1)))) @@ -5925,8 +5925,6 @@ class binary_reader } *out++ = static_cast(current); } - - return true; } /*! @@ -5971,7 +5969,7 @@ class binary_reader } // All BSON binary values have a subtype - std::uint8_t subtype; + std::uint8_t subtype{}; get_number(input_format_t::bson, subtype); result.set_subtype(subtype); @@ -5995,13 +5993,13 @@ class binary_reader { case 0x01: // double { - double number; + double number{}; return get_number(input_format_t::bson, number) and sax->number_float(static_cast(number), ""); } case 0x02: // string { - std::int32_t len; + std::int32_t len{}; string_t value; return get_number(input_format_t::bson, len) and get_bson_string(len, value) and sax->string(value); } @@ -6018,7 +6016,7 @@ class binary_reader case 0x05: // binary { - std::int32_t len; + std::int32_t len{}; binary_t value; return get_number(input_format_t::bson, len) and get_bson_binary(len, value) and sax->binary(value); } @@ -6035,13 +6033,13 @@ class binary_reader case 0x10: // int32 { - std::int32_t value; + std::int32_t value{}; return get_number(input_format_t::bson, value) and sax->number_integer(value); } case 0x12: // int64 { - std::int64_t value; + std::int64_t value{}; return get_number(input_format_t::bson, value) and sax->number_integer(value); } @@ -6106,7 +6104,7 @@ class binary_reader */ bool parse_bson_array() { - std::int32_t document_size; + std::int32_t document_size{}; get_number(input_format_t::bson, document_size); if (JSON_HEDLEY_UNLIKELY(not sax->start_array(std::size_t(-1)))) @@ -6170,25 +6168,25 @@ class binary_reader case 0x18: // Unsigned integer (one-byte uint8_t follows) { - std::uint8_t number; + std::uint8_t number{}; return get_number(input_format_t::cbor, number) and sax->number_unsigned(number); } case 0x19: // Unsigned integer (two-byte uint16_t follows) { - std::uint16_t number; + std::uint16_t number{}; return get_number(input_format_t::cbor, number) and sax->number_unsigned(number); } case 0x1A: // Unsigned integer (four-byte uint32_t follows) { - std::uint32_t number; + std::uint32_t number{}; return get_number(input_format_t::cbor, number) and sax->number_unsigned(number); } case 0x1B: // Unsigned integer (eight-byte uint64_t follows) { - std::uint64_t number; + std::uint64_t number{}; return get_number(input_format_t::cbor, number) and sax->number_unsigned(number); } @@ -6221,25 +6219,25 @@ class binary_reader case 0x38: // Negative integer (one-byte uint8_t follows) { - std::uint8_t number; + std::uint8_t number{}; return get_number(input_format_t::cbor, number) and sax->number_integer(static_cast(-1) - number); } case 0x39: // Negative integer -1-n (two-byte uint16_t follows) { - std::uint16_t number; + std::uint16_t number{}; return get_number(input_format_t::cbor, number) and sax->number_integer(static_cast(-1) - number); } case 0x3A: // Negative integer -1-n (four-byte uint32_t follows) { - std::uint32_t number; + std::uint32_t number{}; return get_number(input_format_t::cbor, number) and sax->number_integer(static_cast(-1) - number); } case 0x3B: // Negative integer -1-n (eight-byte uint64_t follows) { - std::uint64_t number; + std::uint64_t number{}; return get_number(input_format_t::cbor, number) and sax->number_integer(static_cast(-1) - static_cast(number)); } @@ -6343,25 +6341,25 @@ class binary_reader case 0x98: // array (one-byte uint8_t for n follows) { - std::uint8_t len; + std::uint8_t len{}; return get_number(input_format_t::cbor, len) and get_cbor_array(static_cast(len)); } case 0x99: // array (two-byte uint16_t for n follow) { - std::uint16_t len; + std::uint16_t len{}; return get_number(input_format_t::cbor, len) and get_cbor_array(static_cast(len)); } case 0x9A: // array (four-byte uint32_t for n follow) { - std::uint32_t len; + std::uint32_t len{}; return get_number(input_format_t::cbor, len) and get_cbor_array(static_cast(len)); } case 0x9B: // array (eight-byte uint64_t for n follow) { - std::uint64_t len; + std::uint64_t len{}; return get_number(input_format_t::cbor, len) and get_cbor_array(static_cast(len)); } @@ -6397,25 +6395,25 @@ class binary_reader case 0xB8: // map (one-byte uint8_t for n follows) { - std::uint8_t len; + std::uint8_t len{}; return get_number(input_format_t::cbor, len) and get_cbor_object(static_cast(len)); } case 0xB9: // map (two-byte uint16_t for n follow) { - std::uint16_t len; + std::uint16_t len{}; return get_number(input_format_t::cbor, len) and get_cbor_object(static_cast(len)); } case 0xBA: // map (four-byte uint32_t for n follow) { - std::uint32_t len; + std::uint32_t len{}; return get_number(input_format_t::cbor, len) and get_cbor_object(static_cast(len)); } case 0xBB: // map (eight-byte uint64_t for n follow) { - std::uint64_t len; + std::uint64_t len{}; return get_number(input_format_t::cbor, len) and get_cbor_object(static_cast(len)); } @@ -6481,13 +6479,13 @@ class binary_reader case 0xFA: // Single-Precision Float (four-byte IEEE 754) { - float number; + float number{}; return get_number(input_format_t::cbor, number) and sax->number_float(static_cast(number), ""); } case 0xFB: // Double-Precision Float (eight-byte IEEE 754) { - double number; + double number{}; return get_number(input_format_t::cbor, number) and sax->number_float(static_cast(number), ""); } @@ -6550,25 +6548,25 @@ class binary_reader case 0x78: // UTF-8 string (one-byte uint8_t for n follows) { - std::uint8_t len; + std::uint8_t len{}; return get_number(input_format_t::cbor, len) and get_string(input_format_t::cbor, len, result); } case 0x79: // UTF-8 string (two-byte uint16_t for n follow) { - std::uint16_t len; + std::uint16_t len{}; return get_number(input_format_t::cbor, len) and get_string(input_format_t::cbor, len, result); } case 0x7A: // UTF-8 string (four-byte uint32_t for n follow) { - std::uint32_t len; + std::uint32_t len{}; return get_number(input_format_t::cbor, len) and get_string(input_format_t::cbor, len, result); } case 0x7B: // UTF-8 string (eight-byte uint64_t for n follow) { - std::uint64_t len; + std::uint64_t len{}; return get_number(input_format_t::cbor, len) and get_string(input_format_t::cbor, len, result); } @@ -6645,28 +6643,28 @@ class binary_reader case 0x58: // Binary data (one-byte uint8_t for n follows) { - std::uint8_t len; + std::uint8_t len{}; return get_number(input_format_t::cbor, len) and get_binary(input_format_t::cbor, len, result); } case 0x59: // Binary data (two-byte uint16_t for n follow) { - std::uint16_t len; + std::uint16_t len{}; return get_number(input_format_t::cbor, len) and get_binary(input_format_t::cbor, len, result); } case 0x5A: // Binary data (four-byte uint32_t for n follow) { - std::uint32_t len; + std::uint32_t len{}; return get_number(input_format_t::cbor, len) and get_binary(input_format_t::cbor, len, result); } case 0x5B: // Binary data (eight-byte uint64_t for n follow) { - std::uint64_t len; + std::uint64_t len{}; return get_number(input_format_t::cbor, len) and get_binary(input_format_t::cbor, len, result); } @@ -7031,85 +7029,85 @@ class binary_reader case 0xCA: // float 32 { - float number; + float number{}; return get_number(input_format_t::msgpack, number) and sax->number_float(static_cast(number), ""); } case 0xCB: // float 64 { - double number; + double number{}; return get_number(input_format_t::msgpack, number) and sax->number_float(static_cast(number), ""); } case 0xCC: // uint 8 { - std::uint8_t number; + std::uint8_t number{}; return get_number(input_format_t::msgpack, number) and sax->number_unsigned(number); } case 0xCD: // uint 16 { - std::uint16_t number; + std::uint16_t number{}; return get_number(input_format_t::msgpack, number) and sax->number_unsigned(number); } case 0xCE: // uint 32 { - std::uint32_t number; + std::uint32_t number{}; return get_number(input_format_t::msgpack, number) and sax->number_unsigned(number); } case 0xCF: // uint 64 { - std::uint64_t number; + std::uint64_t number{}; return get_number(input_format_t::msgpack, number) and sax->number_unsigned(number); } case 0xD0: // int 8 { - std::int8_t number; + std::int8_t number{}; return get_number(input_format_t::msgpack, number) and sax->number_integer(number); } case 0xD1: // int 16 { - std::int16_t number; + std::int16_t number{}; return get_number(input_format_t::msgpack, number) and sax->number_integer(number); } case 0xD2: // int 32 { - std::int32_t number; + std::int32_t number{}; return get_number(input_format_t::msgpack, number) and sax->number_integer(number); } case 0xD3: // int 64 { - std::int64_t number; + std::int64_t number{}; return get_number(input_format_t::msgpack, number) and sax->number_integer(number); } case 0xDC: // array 16 { - std::uint16_t len; + std::uint16_t len{}; return get_number(input_format_t::msgpack, len) and get_msgpack_array(static_cast(len)); } case 0xDD: // array 32 { - std::uint32_t len; + std::uint32_t len{}; return get_number(input_format_t::msgpack, len) and get_msgpack_array(static_cast(len)); } case 0xDE: // map 16 { - std::uint16_t len; + std::uint16_t len{}; return get_number(input_format_t::msgpack, len) and get_msgpack_object(static_cast(len)); } case 0xDF: // map 32 { - std::uint32_t len; + std::uint32_t len{}; return get_number(input_format_t::msgpack, len) and get_msgpack_object(static_cast(len)); } @@ -7214,19 +7212,19 @@ class binary_reader case 0xD9: // str 8 { - std::uint8_t len; + std::uint8_t len{}; return get_number(input_format_t::msgpack, len) and get_string(input_format_t::msgpack, len, result); } case 0xDA: // str 16 { - std::uint16_t len; + std::uint16_t len{}; return get_number(input_format_t::msgpack, len) and get_string(input_format_t::msgpack, len, result); } case 0xDB: // str 32 { - std::uint32_t len; + std::uint32_t len{}; return get_number(input_format_t::msgpack, len) and get_string(input_format_t::msgpack, len, result); } @@ -7261,29 +7259,29 @@ class binary_reader { case 0xC4: // bin 8 { - std::uint8_t len; + std::uint8_t len{}; return get_number(input_format_t::msgpack, len) and get_binary(input_format_t::msgpack, len, result); } case 0xC5: // bin 16 { - std::uint16_t len; + std::uint16_t len{}; return get_number(input_format_t::msgpack, len) and get_binary(input_format_t::msgpack, len, result); } case 0xC6: // bin 32 { - std::uint32_t len; + std::uint32_t len{}; return get_number(input_format_t::msgpack, len) and get_binary(input_format_t::msgpack, len, result); } case 0xC7: // ext 8 { - std::uint8_t len; - std::int8_t subtype; + std::uint8_t len{}; + std::int8_t subtype{}; return get_number(input_format_t::msgpack, len) and get_number(input_format_t::msgpack, subtype) and get_binary(input_format_t::msgpack, len, result) and @@ -7292,8 +7290,8 @@ class binary_reader case 0xC8: // ext 16 { - std::uint16_t len; - std::int8_t subtype; + std::uint16_t len{}; + std::int8_t subtype{}; return get_number(input_format_t::msgpack, len) and get_number(input_format_t::msgpack, subtype) and get_binary(input_format_t::msgpack, len, result) and @@ -7302,8 +7300,8 @@ class binary_reader case 0xC9: // ext 32 { - std::uint32_t len; - std::int8_t subtype; + std::uint32_t len{}; + std::int8_t subtype{}; return get_number(input_format_t::msgpack, len) and get_number(input_format_t::msgpack, subtype) and get_binary(input_format_t::msgpack, len, result) and @@ -7312,7 +7310,7 @@ class binary_reader case 0xD4: // fixext 1 { - std::int8_t subtype; + std::int8_t subtype{}; return get_number(input_format_t::msgpack, subtype) and get_binary(input_format_t::msgpack, 1, result) and assign_and_return_true(subtype); @@ -7320,7 +7318,7 @@ class binary_reader case 0xD5: // fixext 2 { - std::int8_t subtype; + std::int8_t subtype{}; return get_number(input_format_t::msgpack, subtype) and get_binary(input_format_t::msgpack, 2, result) and assign_and_return_true(subtype); @@ -7328,7 +7326,7 @@ class binary_reader case 0xD6: // fixext 4 { - std::int8_t subtype; + std::int8_t subtype{}; return get_number(input_format_t::msgpack, subtype) and get_binary(input_format_t::msgpack, 4, result) and assign_and_return_true(subtype); @@ -7336,7 +7334,7 @@ class binary_reader case 0xD7: // fixext 8 { - std::int8_t subtype; + std::int8_t subtype{}; return get_number(input_format_t::msgpack, subtype) and get_binary(input_format_t::msgpack, 8, result) and assign_and_return_true(subtype); @@ -7344,7 +7342,7 @@ class binary_reader case 0xD8: // fixext 16 { - std::int8_t subtype; + std::int8_t subtype{}; return get_number(input_format_t::msgpack, subtype) and get_binary(input_format_t::msgpack, 16, result) and assign_and_return_true(subtype); @@ -7453,31 +7451,31 @@ class binary_reader { case 'U': { - std::uint8_t len; + std::uint8_t len{}; return get_number(input_format_t::ubjson, len) and get_string(input_format_t::ubjson, len, result); } case 'i': { - std::int8_t len; + std::int8_t len{}; return get_number(input_format_t::ubjson, len) and get_string(input_format_t::ubjson, len, result); } case 'I': { - std::int16_t len; + std::int16_t len{}; return get_number(input_format_t::ubjson, len) and get_string(input_format_t::ubjson, len, result); } case 'l': { - std::int32_t len; + std::int32_t len{}; return get_number(input_format_t::ubjson, len) and get_string(input_format_t::ubjson, len, result); } case 'L': { - std::int64_t len; + std::int64_t len{}; return get_number(input_format_t::ubjson, len) and get_string(input_format_t::ubjson, len, result); } @@ -7497,7 +7495,7 @@ class binary_reader { case 'U': { - std::uint8_t number; + std::uint8_t number{}; if (JSON_HEDLEY_UNLIKELY(not get_number(input_format_t::ubjson, number))) { return false; @@ -7508,7 +7506,7 @@ class binary_reader case 'i': { - std::int8_t number; + std::int8_t number{}; if (JSON_HEDLEY_UNLIKELY(not get_number(input_format_t::ubjson, number))) { return false; @@ -7519,7 +7517,7 @@ class binary_reader case 'I': { - std::int16_t number; + std::int16_t number{}; if (JSON_HEDLEY_UNLIKELY(not get_number(input_format_t::ubjson, number))) { return false; @@ -7530,7 +7528,7 @@ class binary_reader case 'l': { - std::int32_t number; + std::int32_t number{}; if (JSON_HEDLEY_UNLIKELY(not get_number(input_format_t::ubjson, number))) { return false; @@ -7541,7 +7539,7 @@ class binary_reader case 'L': { - std::int64_t number; + std::int64_t number{}; if (JSON_HEDLEY_UNLIKELY(not get_number(input_format_t::ubjson, number))) { return false; @@ -7626,43 +7624,43 @@ class binary_reader case 'U': { - std::uint8_t number; + std::uint8_t number{}; return get_number(input_format_t::ubjson, number) and sax->number_unsigned(number); } case 'i': { - std::int8_t number; + std::int8_t number{}; return get_number(input_format_t::ubjson, number) and sax->number_integer(number); } case 'I': { - std::int16_t number; + std::int16_t number{}; return get_number(input_format_t::ubjson, number) and sax->number_integer(number); } case 'l': { - std::int32_t number; + std::int32_t number{}; return get_number(input_format_t::ubjson, number) and sax->number_integer(number); } case 'L': { - std::int64_t number; + std::int64_t number{}; return get_number(input_format_t::ubjson, number) and sax->number_integer(number); } case 'd': { - float number; + float number{}; return get_number(input_format_t::ubjson, number) and sax->number_float(static_cast(number), ""); } case 'D': { - double number; + double number{}; return get_number(input_format_t::ubjson, number) and sax->number_float(static_cast(number), ""); } @@ -8202,7 +8200,7 @@ class lexer : public lexer_base JSON_HEDLEY_PURE static char get_decimal_point() noexcept { - const auto loc = localeconv(); + const auto* loc = localeconv(); assert(loc != nullptr); return (loc->decimal_point == nullptr) ? '.' : *(loc->decimal_point); } @@ -10249,8 +10247,6 @@ template struct internal_iterator typename BasicJsonType::object_t::iterator object_iterator {}; /// iterator for JSON arrays typename BasicJsonType::array_t::iterator array_iterator {}; - /// iterator for JSON binary arrays - typename BasicJsonType::binary_t::container_type::iterator binary_iterator {}; /// generic iterator for all other types primitive_iterator_t primitive_iterator {}; }; @@ -12026,23 +12022,30 @@ class json_ref using value_type = BasicJsonType; json_ref(value_type&& value) - : owned_value(std::move(value)), value_ref(&owned_value), is_rvalue(true) + : owned_value(std::move(value)) + , value_ref(&owned_value) + , is_rvalue(true) {} json_ref(const value_type& value) - : value_ref(const_cast(&value)), is_rvalue(false) + : value_ref(const_cast(&value)) + , is_rvalue(false) {} json_ref(std::initializer_list init) - : owned_value(init), value_ref(&owned_value), is_rvalue(true) + : owned_value(init) + , value_ref(&owned_value) + , is_rvalue(true) {} template < class... Args, enable_if_t::value, int> = 0 > json_ref(Args && ... args) - : owned_value(std::forward(args)...), value_ref(&owned_value), - is_rvalue(true) {} + : owned_value(std::forward(args)...) + , value_ref(&owned_value) + , is_rvalue(true) + {} // class should be movable only json_ref(json_ref&&) = default; @@ -12073,7 +12076,7 @@ class json_ref private: mutable value_type owned_value = nullptr; value_type* value_ref = nullptr; - const bool is_rvalue; + const bool is_rvalue = true; }; } // namespace detail } // namespace nlohmann @@ -12787,7 +12790,7 @@ class binary_writer const auto N = j.m_value.binary->size(); if (N <= (std::numeric_limits::max)()) { - std::uint8_t output_type; + std::uint8_t output_type{}; bool fixed = true; if (use_ext) { @@ -12829,30 +12832,18 @@ class binary_writer } else if (N <= (std::numeric_limits::max)()) { - std::uint8_t output_type; - if (use_ext) - { - output_type = 0xC8; // ext 16 - } - else - { - output_type = 0xC5; // bin 16 - } + std::uint8_t output_type = use_ext + ? 0xC8 // ext 16 + : 0xC5; // bin 16 oa->write_character(to_char_type(output_type)); write_number(static_cast(N)); } else if (N <= (std::numeric_limits::max)()) { - std::uint8_t output_type; - if (use_ext) - { - output_type = 0xC9; // ext 32 - } - else - { - output_type = 0xC6; // bin 32 - } + std::uint8_t output_type = use_ext + ? 0xC9 // ext 32 + : 0xC6; // bin 32 oa->write_character(to_char_type(output_type)); write_number(static_cast(N)); @@ -13806,7 +13797,7 @@ class binary_writer #include // uint8_t #include // snprintf #include // numeric_limits -#include // string +#include // string, char_traits #include // is_same #include // move @@ -14973,8 +14964,8 @@ class serializer error_handler_t error_handler_ = error_handler_t::strict) : o(std::move(s)) , loc(std::localeconv()) - , thousands_sep(loc->thousands_sep == nullptr ? '\0' : * (loc->thousands_sep)) - , decimal_point(loc->decimal_point == nullptr ? '\0' : * (loc->decimal_point)) + , thousands_sep(loc->thousands_sep == nullptr ? '\0' : std::char_traits::to_char_type(* (loc->thousands_sep))) + , decimal_point(loc->decimal_point == nullptr ? '\0' : std::char_traits::to_char_type(* (loc->decimal_point))) , indent_char(ichar) , indent_string(512, indent_char) , error_handler(error_handler_) @@ -15615,7 +15606,7 @@ class serializer } // use a pointer to fill the buffer - auto buffer_ptr = number_buffer.begin(); + auto* buffer_ptr = number_buffer.begin(); const bool is_negative = std::is_same::value and not(x >= 0); // see issue #755 number_unsigned_t abs_value;