From 788e5468e4cb4573941600d5c39ccd552dc8a429 Mon Sep 17 00:00:00 2001 From: Ikko Eltociear Ashimine Date: Sun, 3 Sep 2023 00:16:33 +0900 Subject: [PATCH 01/14] Fix typo in afl_driver.cpp (#4109) --- tests/thirdparty/Fuzzer/afl/afl_driver.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/thirdparty/Fuzzer/afl/afl_driver.cpp b/tests/thirdparty/Fuzzer/afl/afl_driver.cpp index fc9589552..57ee56109 100644 --- a/tests/thirdparty/Fuzzer/afl/afl_driver.cpp +++ b/tests/thirdparty/Fuzzer/afl/afl_driver.cpp @@ -71,7 +71,7 @@ statistics from the file. If that fails then the process will quit. #endif // Used to avoid repeating error checking boilerplate. If cond is false, a -// fatal error has occured in the program. In this event print error_message +// fatal error has occurred in the program. In this event print error_message // to stderr and abort(). Otherwise do nothing. Note that setting // AFL_DRIVER_STDERR_DUPLICATE_FILENAME may cause error_message to be appended // to the file as well, if the error occurs after the duplication is performed. From 836b7beca4b62e2a99465edef44066b7401fd704 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Thu, 7 Sep 2023 20:41:12 +0200 Subject: [PATCH 02/14] Fix CI, again (#4083) --- Makefile | 3 +- docs/examples/at__json_pointer.cpp | 1 - docs/examples/at__keytype.c++17.cpp | 1 - docs/examples/at__keytype_const.c++17.cpp | 1 - docs/examples/at__object_t_key_type.cpp | 1 - docs/examples/at__object_t_key_type_const.cpp | 1 - docs/examples/at__size_type.cpp | 1 - docs/examples/at__size_type_const.cpp | 1 - docs/examples/basic_json__CompatibleType.cpp | 4 - docs/examples/get_to.cpp | 1 - ...rator_spaceship__const_reference.c++20.cpp | 1 - .../operator_spaceship__scalartype.c++20.cpp | 1 - .../parse__istream__parser_callback_t.cpp | 1 - .../parse__string__parser_callback_t.cpp | 1 - include/nlohmann/detail/exceptions.hpp | 1 - .../nlohmann/detail/input/binary_reader.hpp | 1 - .../nlohmann/detail/input/input_adapters.hpp | 3 - include/nlohmann/detail/input/json_sax.hpp | 5 +- .../detail/iterators/iteration_proxy.hpp | 4 +- include/nlohmann/detail/macro_scope.hpp | 1 - include/nlohmann/detail/meta/type_traits.hpp | 3 - include/nlohmann/json.hpp | 30 ++----- single_include/nlohmann/json.hpp | 90 +++---------------- single_include/nlohmann/json_fwd.hpp | 3 - tests/benchmarks/src/benchmarks.cpp | 2 - tests/src/unit-32bit.cpp | 2 - tests/src/unit-algorithms.cpp | 4 - tests/src/unit-alt-string.cpp | 2 - tests/src/unit-bjdata.cpp | 15 ++-- tests/src/unit-bson.cpp | 1 - tests/src/unit-cbor.cpp | 14 +-- tests/src/unit-constructor1.cpp | 1 - tests/src/unit-custom-base-class.cpp | 1 - tests/src/unit-element_access2.cpp | 1 - tests/src/unit-iterators2.cpp | 1 - tests/src/unit-msgpack.cpp | 10 +-- tests/src/unit-ordered_json.cpp | 1 - tests/src/unit-ordered_map.cpp | 1 - tests/src/unit-regression1.cpp | 1 - 39 files changed, 45 insertions(+), 172 deletions(-) diff --git a/Makefile b/Makefile index 6eff8663e..a1b4e7328 100644 --- a/Makefile +++ b/Makefile @@ -156,7 +156,8 @@ pretty: --pad-header \ --align-pointer=type \ --align-reference=type \ - --add-brackets \ + --add-braces \ + --squeeze-lines=2 \ --convert-tabs \ --close-templates \ --lineend=linux \ diff --git a/docs/examples/at__json_pointer.cpp b/docs/examples/at__json_pointer.cpp index 26dfd8edd..9cb6cf9a2 100644 --- a/docs/examples/at__json_pointer.cpp +++ b/docs/examples/at__json_pointer.cpp @@ -35,7 +35,6 @@ int main() // output the changed array std::cout << j["array"] << '\n'; - // out_of_range.106 try { diff --git a/docs/examples/at__keytype.c++17.cpp b/docs/examples/at__keytype.c++17.cpp index 3491cb9f7..e0d9b9e7b 100644 --- a/docs/examples/at__keytype.c++17.cpp +++ b/docs/examples/at__keytype.c++17.cpp @@ -24,7 +24,6 @@ int main() // output changed array std::cout << object << '\n'; - // exception type_error.304 try { diff --git a/docs/examples/at__keytype_const.c++17.cpp b/docs/examples/at__keytype_const.c++17.cpp index ec93c7059..1f32f23a5 100644 --- a/docs/examples/at__keytype_const.c++17.cpp +++ b/docs/examples/at__keytype_const.c++17.cpp @@ -18,7 +18,6 @@ int main() // output element with key "the ugly" using string_view std::cout << object.at("the ugly"sv) << '\n'; - // exception type_error.304 try { diff --git a/docs/examples/at__object_t_key_type.cpp b/docs/examples/at__object_t_key_type.cpp index 202f8a2ee..3a59d1a50 100644 --- a/docs/examples/at__object_t_key_type.cpp +++ b/docs/examples/at__object_t_key_type.cpp @@ -22,7 +22,6 @@ int main() // output changed array std::cout << object << '\n'; - // exception type_error.304 try { diff --git a/docs/examples/at__object_t_key_type_const.cpp b/docs/examples/at__object_t_key_type_const.cpp index e5244f3f7..f41bab61a 100644 --- a/docs/examples/at__object_t_key_type_const.cpp +++ b/docs/examples/at__object_t_key_type_const.cpp @@ -16,7 +16,6 @@ int main() // output element with key "the ugly" std::cout << object.at("the ugly") << '\n'; - // exception type_error.304 try { diff --git a/docs/examples/at__size_type.cpp b/docs/examples/at__size_type.cpp index 65baeddcf..001b51d59 100644 --- a/docs/examples/at__size_type.cpp +++ b/docs/examples/at__size_type.cpp @@ -17,7 +17,6 @@ int main() // output changed array std::cout << array << '\n'; - // exception type_error.304 try { diff --git a/docs/examples/at__size_type_const.cpp b/docs/examples/at__size_type_const.cpp index faa4cffdd..e2bebf7ec 100644 --- a/docs/examples/at__size_type_const.cpp +++ b/docs/examples/at__size_type_const.cpp @@ -11,7 +11,6 @@ int main() // output element at index 2 (third element) std::cout << array.at(2) << '\n'; - // exception type_error.304 try { diff --git a/docs/examples/basic_json__CompatibleType.cpp b/docs/examples/basic_json__CompatibleType.cpp index e2f01aa63..f0d0cc1e7 100644 --- a/docs/examples/basic_json__CompatibleType.cpp +++ b/docs/examples/basic_json__CompatibleType.cpp @@ -55,7 +55,6 @@ int main() std::cout << j_mmap << '\n'; std::cout << j_ummap << "\n\n"; - // =========== // array types // =========== @@ -117,7 +116,6 @@ int main() std::cout << j_mset << '\n'; std::cout << j_umset << "\n\n"; - // ============ // string types // ============ @@ -138,7 +136,6 @@ int main() std::cout << j_string_literal << '\n'; std::cout << j_stdstring << "\n\n"; - // ============ // number types // ============ @@ -203,7 +200,6 @@ int main() std::cout << j_float_nan << '\n'; std::cout << j_double << "\n\n"; - // ============= // boolean types // ============= diff --git a/docs/examples/get_to.cpp b/docs/examples/get_to.cpp index 4705b172f..358c8d43a 100644 --- a/docs/examples/get_to.cpp +++ b/docs/examples/get_to.cpp @@ -30,7 +30,6 @@ int main() std::vector v7; std::unordered_map v8; - // use explicit conversions json_types["boolean"].get_to(v1); json_types["number"]["integer"].get_to(v2); diff --git a/docs/examples/operator_spaceship__const_reference.c++20.cpp b/docs/examples/operator_spaceship__const_reference.c++20.cpp index 3c6c8b8c5..9e7c9e9be 100644 --- a/docs/examples/operator_spaceship__const_reference.c++20.cpp +++ b/docs/examples/operator_spaceship__const_reference.c++20.cpp @@ -32,7 +32,6 @@ int main() json string = "foo"; json discarded = json(json::value_t::discarded); - // output values and comparisons std::cout << array_1 << " <=> " << array_2 << " := " << to_string(array_1 <=> array_2) << '\n'; // *NOPAD* std::cout << object_1 << " <=> " << object_2 << " := " << to_string(object_1 <=> object_2) << '\n'; // *NOPAD* diff --git a/docs/examples/operator_spaceship__scalartype.c++20.cpp b/docs/examples/operator_spaceship__scalartype.c++20.cpp index d9dc3ca49..ebb5b4349 100644 --- a/docs/examples/operator_spaceship__scalartype.c++20.cpp +++ b/docs/examples/operator_spaceship__scalartype.c++20.cpp @@ -31,7 +31,6 @@ int main() json number = 17; json string = "17"; - // output values and comparisons std::cout << std::boolalpha << std::fixed; std::cout << boolean << " <=> " << true << " := " << to_string(boolean <=> true) << '\n'; // *NOPAD* diff --git a/docs/examples/parse__istream__parser_callback_t.cpp b/docs/examples/parse__istream__parser_callback_t.cpp index afcaa39d0..2ef14dab2 100644 --- a/docs/examples/parse__istream__parser_callback_t.cpp +++ b/docs/examples/parse__istream__parser_callback_t.cpp @@ -33,7 +33,6 @@ int main() json j_complete = json::parse(ss); std::cout << std::setw(4) << j_complete << "\n\n"; - // define parser callback json::parser_callback_t cb = [](int depth, json::parse_event_t event, json & parsed) { diff --git a/docs/examples/parse__string__parser_callback_t.cpp b/docs/examples/parse__string__parser_callback_t.cpp index 2ae4410a8..19c6c448a 100644 --- a/docs/examples/parse__string__parser_callback_t.cpp +++ b/docs/examples/parse__string__parser_callback_t.cpp @@ -28,7 +28,6 @@ int main() json j_complete = json::parse(text); std::cout << std::setw(4) << j_complete << "\n\n"; - // define parser callback json::parser_callback_t cb = [](int depth, json::parse_event_t event, json & parsed) { diff --git a/include/nlohmann/detail/exceptions.hpp b/include/nlohmann/detail/exceptions.hpp index 23b390c25..c8c0a1373 100644 --- a/include/nlohmann/detail/exceptions.hpp +++ b/include/nlohmann/detail/exceptions.hpp @@ -25,7 +25,6 @@ #include #include - NLOHMANN_JSON_NAMESPACE_BEGIN namespace detail { diff --git a/include/nlohmann/detail/input/binary_reader.hpp b/include/nlohmann/detail/input/binary_reader.hpp index 832c36ddf..263fdb525 100644 --- a/include/nlohmann/detail/input/binary_reader.hpp +++ b/include/nlohmann/detail/input/binary_reader.hpp @@ -55,7 +55,6 @@ static inline bool little_endianness(int num = 1) noexcept return *reinterpret_cast(&num) == 1; } - /////////////////// // binary reader // /////////////////// diff --git a/include/nlohmann/detail/input/input_adapters.hpp b/include/nlohmann/detail/input/input_adapters.hpp index cf53b1d57..e4ae7a8dc 100644 --- a/include/nlohmann/detail/input/input_adapters.hpp +++ b/include/nlohmann/detail/input/input_adapters.hpp @@ -71,7 +71,6 @@ class file_input_adapter std::FILE* m_file; }; - /*! Input adapter for a (caching) istream. Ignores a UFT Byte Order Mark at beginning of input. Does not support changing the underlying std::streambuf @@ -170,7 +169,6 @@ class iterator_input_adapter } }; - template struct wide_string_input_helper; @@ -339,7 +337,6 @@ class wide_string_input_adapter std::size_t utf8_bytes_filled = 0; }; - template struct iterator_input_adapter_factory { diff --git a/include/nlohmann/detail/input/json_sax.hpp b/include/nlohmann/detail/input/json_sax.hpp index 1bf46c232..ce1c66065 100644 --- a/include/nlohmann/detail/input/json_sax.hpp +++ b/include/nlohmann/detail/input/json_sax.hpp @@ -142,7 +142,6 @@ struct json_sax virtual ~json_sax() = default; }; - namespace detail { /*! @@ -591,7 +590,7 @@ class json_sax_dom_callback_parser if (ref_stack.empty()) { root = std::move(value); - return {true, &root}; + return {true, & root}; } // skip this value if we already decided to skip the parent @@ -608,7 +607,7 @@ class json_sax_dom_callback_parser if (ref_stack.back()->is_array()) { ref_stack.back()->m_data.m_value.array->emplace_back(std::move(value)); - return {true, &(ref_stack.back()->m_data.m_value.array->back())}; + return {true, & (ref_stack.back()->m_data.m_value.array->back())}; } // object diff --git a/include/nlohmann/detail/iterators/iteration_proxy.hpp b/include/nlohmann/detail/iterators/iteration_proxy.hpp index 33bfc36ba..6920c14d2 100644 --- a/include/nlohmann/detail/iterators/iteration_proxy.hpp +++ b/include/nlohmann/detail/iterators/iteration_proxy.hpp @@ -69,10 +69,10 @@ template class iteration_proxy_value // older GCCs are a bit fussy and require explicit noexcept specifiers on defaulted functions iteration_proxy_value(iteration_proxy_value&&) noexcept(std::is_nothrow_move_constructible::value - && std::is_nothrow_move_constructible::value) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor) + && std::is_nothrow_move_constructible::value) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor,cppcoreguidelines-noexcept-move-operations) iteration_proxy_value& operator=(iteration_proxy_value&&) noexcept(std::is_nothrow_move_assignable::value - && std::is_nothrow_move_assignable::value) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor) + && std::is_nothrow_move_assignable::value) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor,cppcoreguidelines-noexcept-move-operations) ~iteration_proxy_value() = default; /// dereference operator (needed for range-based for) diff --git a/include/nlohmann/detail/macro_scope.hpp b/include/nlohmann/detail/macro_scope.hpp index 2870a4f1d..6a463833c 100644 --- a/include/nlohmann/detail/macro_scope.hpp +++ b/include/nlohmann/detail/macro_scope.hpp @@ -411,7 +411,6 @@ inline void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \ inline void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { const Type nlohmann_json_default_obj{}; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) } - // inspired from https://stackoverflow.com/a/26745591 // allows to call any std function as if (e.g. with begin): // using std::begin; begin(x); diff --git a/include/nlohmann/detail/meta/type_traits.hpp b/include/nlohmann/detail/meta/type_traits.hpp index cfc7e5ad3..d2788bbd7 100644 --- a/include/nlohmann/detail/meta/type_traits.hpp +++ b/include/nlohmann/detail/meta/type_traits.hpp @@ -217,7 +217,6 @@ template struct is_default_constructible> : conjunction...> {}; - template struct is_constructible : std::is_constructible {}; @@ -233,7 +232,6 @@ struct is_constructible> : is_default_constructible struct is_constructible> : is_default_constructible> {}; - template struct is_iterator_traits : std::false_type {}; @@ -643,7 +641,6 @@ struct value_in_range_of_impl2 } }; - template struct value_in_range_of_impl2 { diff --git a/include/nlohmann/json.hpp b/include/nlohmann/json.hpp index a3c0af1e0..210553490 100644 --- a/include/nlohmann/json.hpp +++ b/include/nlohmann/json.hpp @@ -192,7 +192,6 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec /// @} - ///////////////////// // container types // ///////////////////// @@ -234,7 +233,6 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec /// @} - /// @brief returns the allocator associated with the container /// @sa https://json.nlohmann.me/api/basic_json/get_allocator/ static allocator_type get_allocator() @@ -297,7 +295,6 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec result["compiler"] = {{"family", "unknown"}, {"version", "unknown"}}; #endif - #if defined(_MSVC_LANG) result["compiler"]["c++"] = std::to_string(_MSVC_LANG); #elif defined(__cplusplus) @@ -308,7 +305,6 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec return result; } - /////////////////////////// // JSON value data types // /////////////////////////// @@ -1130,7 +1126,6 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec assert_invariant(); } - /////////////////////////////////////// // other constructors and destructor // /////////////////////////////////////// @@ -1925,7 +1920,6 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec /// @} - //////////////////// // element access // //////////////////// @@ -2640,7 +2634,6 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec /// @} - //////////// // lookup // //////////// @@ -2758,7 +2751,6 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec /// @} - /////////////// // iterators // /////////////// @@ -2897,7 +2889,6 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec /// @} - ////////////// // capacity // ////////////// @@ -3019,7 +3010,6 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec /// @} - /////////////// // modifiers // /////////////// @@ -3467,7 +3457,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec void swap(reference other) noexcept ( std::is_nothrow_move_constructible::value&& std::is_nothrow_move_assignable::value&& - std::is_nothrow_move_constructible::value&& + std::is_nothrow_move_constructible::value&& // NOLINT(cppcoreguidelines-noexcept-swap,performance-noexcept-swap) std::is_nothrow_move_assignable::value ) { @@ -3484,7 +3474,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec friend void swap(reference left, reference right) noexcept ( std::is_nothrow_move_constructible::value&& std::is_nothrow_move_assignable::value&& - std::is_nothrow_move_constructible::value&& + std::is_nothrow_move_constructible::value&& // NOLINT(cppcoreguidelines-noexcept-swap,performance-noexcept-swap) std::is_nothrow_move_assignable::value ) { @@ -3493,7 +3483,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec /// @brief exchanges the values /// @sa https://json.nlohmann.me/api/basic_json/swap/ - void swap(array_t& other) // NOLINT(bugprone-exception-escape) + void swap(array_t& other) // NOLINT(bugprone-exception-escape,cppcoreguidelines-noexcept-swap,performance-noexcept-swap) { // swap only works for arrays if (JSON_HEDLEY_LIKELY(is_array())) @@ -3509,7 +3499,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec /// @brief exchanges the values /// @sa https://json.nlohmann.me/api/basic_json/swap/ - void swap(object_t& other) // NOLINT(bugprone-exception-escape) + void swap(object_t& other) // NOLINT(bugprone-exception-escape,cppcoreguidelines-noexcept-swap,performance-noexcept-swap) { // swap only works for objects if (JSON_HEDLEY_LIKELY(is_object())) @@ -3525,7 +3515,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec /// @brief exchanges the values /// @sa https://json.nlohmann.me/api/basic_json/swap/ - void swap(string_t& other) // NOLINT(bugprone-exception-escape) + void swap(string_t& other) // NOLINT(bugprone-exception-escape,cppcoreguidelines-noexcept-swap,performance-noexcept-swap) { // swap only works for strings if (JSON_HEDLEY_LIKELY(is_string())) @@ -3541,7 +3531,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec /// @brief exchanges the values /// @sa https://json.nlohmann.me/api/basic_json/swap/ - void swap(binary_t& other) // NOLINT(bugprone-exception-escape) + void swap(binary_t& other) // NOLINT(bugprone-exception-escape,cppcoreguidelines-noexcept-swap,performance-noexcept-swap) { // swap only works for strings if (JSON_HEDLEY_LIKELY(is_binary())) @@ -4006,7 +3996,6 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec #endif // JSON_NO_IO /// @} - ///////////////////// // deserialization // ///////////////////// @@ -4187,7 +4176,6 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec } } - JSON_PRIVATE_UNLESS_TESTED: ////////////////////// // member variables // @@ -4405,7 +4393,6 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec return from_cbor(ptr, ptr + len, strict, allow_exceptions, tag_handler); } - JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_cbor(ptr, ptr + len)) static basic_json from_cbor(detail::span_input_adapter&& i, @@ -4529,7 +4516,6 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec return res ? result : basic_json(value_t::discarded); } - /// @brief create a JSON value from an input in BJData format /// @sa https://json.nlohmann.me/api/basic_json/from_bjdata/ template @@ -4810,7 +4796,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec }; // wrapper for "remove" operation; remove value at ptr - const auto operation_remove = [this, &result](json_pointer & ptr) + const auto operation_remove = [this, & result](json_pointer & ptr) { // get reference to parent of JSON pointer ptr const auto last_path = ptr.back(); @@ -5234,7 +5220,7 @@ struct less< ::nlohmann::detail::value_t> // do not remove the space after '<', /// @sa https://json.nlohmann.me/api/basic_json/std_swap/ NLOHMANN_BASIC_JSON_TPL_DECLARATION inline void swap(nlohmann::NLOHMANN_BASIC_JSON_TPL& j1, nlohmann::NLOHMANN_BASIC_JSON_TPL& j2) noexcept( // NOLINT(readability-inconsistent-declaration-parameter-name, cert-dcl58-cpp) - is_nothrow_move_constructible::value&& // NOLINT(misc-redundant-expression) + is_nothrow_move_constructible::value&& // NOLINT(misc-redundant-expression,cppcoreguidelines-noexcept-swap,performance-noexcept-swap) is_nothrow_move_assignable::value) { j1.swap(j2); diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index ddd3131dc..f44b20163 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -41,7 +41,6 @@ // SPDX-License-Identifier: MIT - #include // #include @@ -54,7 +53,6 @@ // SPDX-License-Identifier: MIT - // This file contains all macro definitions affecting or depending on the ABI #ifndef JSON_SKIP_LIBRARY_VERSION_CHECK @@ -156,7 +154,6 @@ // SPDX-License-Identifier: MIT - #include // transform #include // array #include // forward_list @@ -179,7 +176,6 @@ // SPDX-License-Identifier: MIT - #include // nullptr_t #include // exception #if JSON_DIAGNOSTICS @@ -199,7 +195,6 @@ // SPDX-License-Identifier: MIT - #include // array #include // size_t #include // uint8_t @@ -215,7 +210,6 @@ // SPDX-License-Identifier: MIT - #include // declval, pair // #include // __ _____ _____ _____ @@ -227,7 +221,6 @@ // SPDX-License-Identifier: MIT - #include // #include @@ -240,7 +233,6 @@ // SPDX-License-Identifier: MIT - // #include @@ -2763,7 +2755,6 @@ JSON_HEDLEY_DIAGNOSTIC_POP inline void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \ inline void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { const Type nlohmann_json_default_obj{}; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) } - // inspired from https://stackoverflow.com/a/26745591 // allows to call any std function as if (e.g. with begin): // using std::begin; begin(x); @@ -2933,7 +2924,6 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT - // #include @@ -3008,7 +2998,6 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT - #include // size_t // #include @@ -3051,7 +3040,6 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT - #include // array #include // size_t #include // conditional, enable_if, false_type, integral_constant, is_constructible, is_integral, is_same, remove_cv, remove_reference, true_type @@ -3224,7 +3212,6 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT - #include // numeric_limits #include // false_type, is_constructible, is_integral, is_same, true_type #include // declval @@ -3240,7 +3227,6 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT - #include // random_access_iterator_tag // #include @@ -3308,7 +3294,6 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT - // #include @@ -3328,7 +3313,6 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT - // #include @@ -3617,7 +3601,6 @@ template struct is_default_constructible> : conjunction...> {}; - template struct is_constructible : std::is_constructible {}; @@ -3633,7 +3616,6 @@ struct is_constructible> : is_default_constructible struct is_constructible> : is_default_constructible> {}; - template struct is_iterator_traits : std::false_type {}; @@ -4043,7 +4025,6 @@ struct value_in_range_of_impl2 } }; - template struct value_in_range_of_impl2 { @@ -4149,7 +4130,6 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT - #include // strlen #include // string #include // forward @@ -4290,7 +4270,6 @@ inline OutStringType concat(Args && ... args) NLOHMANN_JSON_NAMESPACE_END - NLOHMANN_JSON_NAMESPACE_BEGIN namespace detail { @@ -4536,7 +4515,6 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT - // #include @@ -4560,7 +4538,6 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT - // #include @@ -5066,7 +5043,6 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT - #include // copy #include // begin, end #include // string @@ -5086,7 +5062,6 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT - #include // size_t #include // input_iterator_tag #include // string, to_string @@ -5151,10 +5126,10 @@ template class iteration_proxy_value // older GCCs are a bit fussy and require explicit noexcept specifiers on defaulted functions iteration_proxy_value(iteration_proxy_value&&) noexcept(std::is_nothrow_move_constructible::value - && std::is_nothrow_move_constructible::value) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor) + && std::is_nothrow_move_constructible::value) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor,cppcoreguidelines-noexcept-move-operations) iteration_proxy_value& operator=(iteration_proxy_value&&) noexcept(std::is_nothrow_move_assignable::value - && std::is_nothrow_move_assignable::value) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor) + && std::is_nothrow_move_assignable::value) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor,cppcoreguidelines-noexcept-move-operations) ~iteration_proxy_value() = default; /// dereference operator (needed for range-based for) @@ -5807,7 +5782,6 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT - #include // uint8_t, uint64_t #include // tie #include // move @@ -5919,7 +5893,6 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT - #include // uint8_t #include // size_t #include // hash @@ -6052,7 +6025,6 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT - #include // generate_n #include // array #include // ldexp @@ -6078,7 +6050,6 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT - #include // array #include // size_t #include // strlen @@ -6144,7 +6115,6 @@ class file_input_adapter std::FILE* m_file; }; - /*! Input adapter for a (caching) istream. Ignores a UFT Byte Order Mark at beginning of input. Does not support changing the underlying std::streambuf @@ -6243,7 +6213,6 @@ class iterator_input_adapter } }; - template struct wide_string_input_helper; @@ -6412,7 +6381,6 @@ class wide_string_input_adapter std::size_t utf8_bytes_filled = 0; }; - template struct iterator_input_adapter_factory { @@ -6576,7 +6544,6 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT - #include #include // string #include // move @@ -6714,7 +6681,6 @@ struct json_sax virtual ~json_sax() = default; }; - namespace detail { /*! @@ -7163,7 +7129,7 @@ class json_sax_dom_callback_parser if (ref_stack.empty()) { root = std::move(value); - return {true, &root}; + return {true, & root}; } // skip this value if we already decided to skip the parent @@ -7180,7 +7146,7 @@ class json_sax_dom_callback_parser if (ref_stack.back()->is_array()) { ref_stack.back()->m_data.m_value.array->emplace_back(std::move(value)); - return {true, &(ref_stack.back()->m_data.m_value.array->back())}; + return {true, & (ref_stack.back()->m_data.m_value.array->back())}; } // object @@ -7309,7 +7275,6 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT - #include // array #include // localeconv #include // size_t @@ -8948,7 +8913,6 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT - #include // size_t #include // declval #include // string @@ -9133,7 +9097,6 @@ static inline bool little_endianness(int num = 1) noexcept return *reinterpret_cast(&num) == 1; } - /////////////////// // binary reader // /////////////////// @@ -12101,7 +12064,6 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT - #include // isfinite #include // uint8_t #include // function @@ -12618,7 +12580,6 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT - // #include // #include @@ -12631,7 +12592,6 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT - #include // ptrdiff_t #include // numeric_limits @@ -12790,7 +12750,6 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT - #include // iterator, random_access_iterator_tag, bidirectional_iterator_tag, advance, next #include // conditional, is_const, remove_const @@ -13552,7 +13511,6 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT - #include // ptrdiff_t #include // reverse_iterator #include // declval @@ -13721,7 +13679,6 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT - #include // all_of #include // isdigit #include // errno, ERANGE @@ -14716,7 +14673,6 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT - #include #include @@ -14808,7 +14764,6 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT - #include // reverse #include // array #include // map @@ -14834,7 +14789,6 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT - #include // copy #include // size_t #include // back_inserter @@ -16803,7 +16757,6 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT - #include // reverse, remove, fill, find, none_of #include // array #include // localeconv, lconv @@ -16828,7 +16781,6 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT - #include // array #include // signbit, isfinite #include // intN_t, uintN_t @@ -18923,7 +18875,6 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT - #include // equal_to, less #include // initializer_list #include // input_iterator_tag, iterator_traits @@ -19408,7 +19359,6 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec /// @} - ///////////////////// // container types // ///////////////////// @@ -19450,7 +19400,6 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec /// @} - /// @brief returns the allocator associated with the container /// @sa https://json.nlohmann.me/api/basic_json/get_allocator/ static allocator_type get_allocator() @@ -19513,7 +19462,6 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec result["compiler"] = {{"family", "unknown"}, {"version", "unknown"}}; #endif - #if defined(_MSVC_LANG) result["compiler"]["c++"] = std::to_string(_MSVC_LANG); #elif defined(__cplusplus) @@ -19524,7 +19472,6 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec return result; } - /////////////////////////// // JSON value data types // /////////////////////////// @@ -20346,7 +20293,6 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec assert_invariant(); } - /////////////////////////////////////// // other constructors and destructor // /////////////////////////////////////// @@ -21141,7 +21087,6 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec /// @} - //////////////////// // element access // //////////////////// @@ -21856,7 +21801,6 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec /// @} - //////////// // lookup // //////////// @@ -21974,7 +21918,6 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec /// @} - /////////////// // iterators // /////////////// @@ -22113,7 +22056,6 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec /// @} - ////////////// // capacity // ////////////// @@ -22235,7 +22177,6 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec /// @} - /////////////// // modifiers // /////////////// @@ -22683,7 +22624,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec void swap(reference other) noexcept ( std::is_nothrow_move_constructible::value&& std::is_nothrow_move_assignable::value&& - std::is_nothrow_move_constructible::value&& + std::is_nothrow_move_constructible::value&& // NOLINT(cppcoreguidelines-noexcept-swap,performance-noexcept-swap) std::is_nothrow_move_assignable::value ) { @@ -22700,7 +22641,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec friend void swap(reference left, reference right) noexcept ( std::is_nothrow_move_constructible::value&& std::is_nothrow_move_assignable::value&& - std::is_nothrow_move_constructible::value&& + std::is_nothrow_move_constructible::value&& // NOLINT(cppcoreguidelines-noexcept-swap,performance-noexcept-swap) std::is_nothrow_move_assignable::value ) { @@ -22709,7 +22650,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec /// @brief exchanges the values /// @sa https://json.nlohmann.me/api/basic_json/swap/ - void swap(array_t& other) // NOLINT(bugprone-exception-escape) + void swap(array_t& other) // NOLINT(bugprone-exception-escape,cppcoreguidelines-noexcept-swap,performance-noexcept-swap) { // swap only works for arrays if (JSON_HEDLEY_LIKELY(is_array())) @@ -22725,7 +22666,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec /// @brief exchanges the values /// @sa https://json.nlohmann.me/api/basic_json/swap/ - void swap(object_t& other) // NOLINT(bugprone-exception-escape) + void swap(object_t& other) // NOLINT(bugprone-exception-escape,cppcoreguidelines-noexcept-swap,performance-noexcept-swap) { // swap only works for objects if (JSON_HEDLEY_LIKELY(is_object())) @@ -22741,7 +22682,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec /// @brief exchanges the values /// @sa https://json.nlohmann.me/api/basic_json/swap/ - void swap(string_t& other) // NOLINT(bugprone-exception-escape) + void swap(string_t& other) // NOLINT(bugprone-exception-escape,cppcoreguidelines-noexcept-swap,performance-noexcept-swap) { // swap only works for strings if (JSON_HEDLEY_LIKELY(is_string())) @@ -22757,7 +22698,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec /// @brief exchanges the values /// @sa https://json.nlohmann.me/api/basic_json/swap/ - void swap(binary_t& other) // NOLINT(bugprone-exception-escape) + void swap(binary_t& other) // NOLINT(bugprone-exception-escape,cppcoreguidelines-noexcept-swap,performance-noexcept-swap) { // swap only works for strings if (JSON_HEDLEY_LIKELY(is_binary())) @@ -23222,7 +23163,6 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec #endif // JSON_NO_IO /// @} - ///////////////////// // deserialization // ///////////////////// @@ -23403,7 +23343,6 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec } } - JSON_PRIVATE_UNLESS_TESTED: ////////////////////// // member variables // @@ -23621,7 +23560,6 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec return from_cbor(ptr, ptr + len, strict, allow_exceptions, tag_handler); } - JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_cbor(ptr, ptr + len)) static basic_json from_cbor(detail::span_input_adapter&& i, @@ -23745,7 +23683,6 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec return res ? result : basic_json(value_t::discarded); } - /// @brief create a JSON value from an input in BJData format /// @sa https://json.nlohmann.me/api/basic_json/from_bjdata/ template @@ -24026,7 +23963,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec }; // wrapper for "remove" operation; remove value at ptr - const auto operation_remove = [this, &result](json_pointer & ptr) + const auto operation_remove = [this, & result](json_pointer & ptr) { // get reference to parent of JSON pointer ptr const auto last_path = ptr.back(); @@ -24450,7 +24387,7 @@ struct less< ::nlohmann::detail::value_t> // do not remove the space after '<', /// @sa https://json.nlohmann.me/api/basic_json/std_swap/ NLOHMANN_BASIC_JSON_TPL_DECLARATION inline void swap(nlohmann::NLOHMANN_BASIC_JSON_TPL& j1, nlohmann::NLOHMANN_BASIC_JSON_TPL& j2) noexcept( // NOLINT(readability-inconsistent-declaration-parameter-name, cert-dcl58-cpp) - is_nothrow_move_constructible::value&& // NOLINT(misc-redundant-expression) + is_nothrow_move_constructible::value&& // NOLINT(misc-redundant-expression,cppcoreguidelines-noexcept-swap,performance-noexcept-swap) is_nothrow_move_assignable::value) { j1.swap(j2); @@ -24475,7 +24412,6 @@ inline void swap(nlohmann::NLOHMANN_BASIC_JSON_TPL& j1, nlohmann::NLOHMANN_BASIC // SPDX-License-Identifier: MIT - // restore clang diagnostic settings #if defined(__clang__) #pragma clang diagnostic pop @@ -24519,7 +24455,6 @@ inline void swap(nlohmann::NLOHMANN_BASIC_JSON_TPL& j1, nlohmann::NLOHMANN_BASIC // SPDX-License-Identifier: MIT - #undef JSON_HEDLEY_ALWAYS_INLINE #undef JSON_HEDLEY_ARM_VERSION #undef JSON_HEDLEY_ARM_VERSION_CHECK @@ -24670,5 +24605,4 @@ inline void swap(nlohmann::NLOHMANN_BASIC_JSON_TPL& j1, nlohmann::NLOHMANN_BASIC #undef JSON_HEDLEY_FALL_THROUGH - #endif // INCLUDE_NLOHMANN_JSON_HPP_ diff --git a/single_include/nlohmann/json_fwd.hpp b/single_include/nlohmann/json_fwd.hpp index 98070dfc9..4940d1e9d 100644 --- a/single_include/nlohmann/json_fwd.hpp +++ b/single_include/nlohmann/json_fwd.hpp @@ -24,8 +24,6 @@ // SPDX-FileCopyrightText: 2013-2022 Niels Lohmann // SPDX-License-Identifier: MIT - - // This file contains all macro definitions affecting or depending on the ABI #ifndef JSON_SKIP_LIBRARY_VERSION_CHECK @@ -117,7 +115,6 @@ } // namespace nlohmann #endif - /*! @brief namespace for Niels Lohmann @see https://github.com/nlohmann diff --git a/tests/benchmarks/src/benchmarks.cpp b/tests/benchmarks/src/benchmarks.cpp index 6c3d4d5a7..a105f692f 100644 --- a/tests/benchmarks/src/benchmarks.cpp +++ b/tests/benchmarks/src/benchmarks.cpp @@ -81,7 +81,6 @@ BENCHMARK_CAPTURE(ParseString, signed_ints, TEST_DATA_DIRECTORY "/regressi BENCHMARK_CAPTURE(ParseString, unsigned_ints, TEST_DATA_DIRECTORY "/regression/unsigned_ints.json"); BENCHMARK_CAPTURE(ParseString, small_signed_ints, TEST_DATA_DIRECTORY "/regression/small_signed_ints.json"); - ////////////////////////////////////////////////////////////////////////////// // serialize JSON ////////////////////////////////////////////////////////////////////////////// @@ -116,7 +115,6 @@ BENCHMARK_CAPTURE(Dump, unsigned_ints / 4, TEST_DATA_DIRECTORY "/regression/ BENCHMARK_CAPTURE(Dump, small_signed_ints / -, TEST_DATA_DIRECTORY "/regression/small_signed_ints.json", -1); BENCHMARK_CAPTURE(Dump, small_signed_ints / 4, TEST_DATA_DIRECTORY "/regression/small_signed_ints.json", 4); - ////////////////////////////////////////////////////////////////////////////// // serialize CBOR ////////////////////////////////////////////////////////////////////////////// diff --git a/tests/src/unit-32bit.cpp b/tests/src/unit-32bit.cpp index d3f9c3ef7..68c1e3ccb 100644 --- a/tests/src/unit-32bit.cpp +++ b/tests/src/unit-32bit.cpp @@ -14,7 +14,6 @@ using nlohmann::json; #include // SIZE_MAX #include // numeric_limits - template struct trait_test_arg { @@ -88,7 +87,6 @@ TEST_CASE_TEMPLATE_DEFINE("value_in_range_of trait", T, value_in_range_of_test) } } - TEST_CASE("32bit") { REQUIRE(SIZE_MAX == 0xffffffff); diff --git a/tests/src/unit-algorithms.cpp b/tests/src/unit-algorithms.cpp index 3ecaacde4..d51479eab 100644 --- a/tests/src/unit-algorithms.cpp +++ b/tests/src/unit-algorithms.cpp @@ -319,7 +319,6 @@ TEST_CASE("algorithms") } } - SECTION("copy") { SECTION("copy without if") @@ -336,7 +335,6 @@ TEST_CASE("algorithms") json dest_arr; const json source_arr = {0, 3, 6, 9, 12, 15, 20}; - std::copy_if(source_arr.begin(), source_arr.end(), std::back_inserter(dest_arr), [](const json & _value) { return _value.get() % 3 == 0; @@ -364,6 +362,4 @@ TEST_CASE("algorithms") } } - - } diff --git a/tests/src/unit-alt-string.cpp b/tests/src/unit-alt-string.cpp index 291c0ad5f..3d6b0704f 100644 --- a/tests/src/unit-alt-string.cpp +++ b/tests/src/unit-alt-string.cpp @@ -14,7 +14,6 @@ #include #include - /* forward declarations */ class alt_string; bool operator<(const char* op1, const alt_string& op2) noexcept; @@ -180,7 +179,6 @@ using alt_json = nlohmann::basic_json < std::allocator, nlohmann::adl_serializer >; - bool operator<(const char* op1, const alt_string& op2) noexcept { return op1 < op2.str_impl; diff --git a/tests/src/unit-bjdata.cpp b/tests/src/unit-bjdata.cpp index f943eb0db..1aa3c22b0 100644 --- a/tests/src/unit-bjdata.cpp +++ b/tests/src/unit-bjdata.cpp @@ -339,13 +339,13 @@ TEST_CASE("BJData") std::vector const numbers { -32769, - -100000, - -1000000, - -10000000, - -100000000, - -1000000000, - -2147483647 - 1, // https://stackoverflow.com/a/29356002/266378 - }; + -100000, + -1000000, + -10000000, + -100000000, + -1000000000, + -2147483647 - 1, // https://stackoverflow.com/a/29356002/266378 + }; for (const auto i : numbers) { CAPTURE(i) @@ -1499,7 +1499,6 @@ TEST_CASE("BJData") } } - SECTION("binary") { SECTION("N = 0..127") diff --git a/tests/src/unit-bson.cpp b/tests/src/unit-bson.cpp index c85e4e1ee..83a385a0a 100644 --- a/tests/src/unit-bson.cpp +++ b/tests/src/unit-bson.cpp @@ -919,7 +919,6 @@ TEST_CASE("BSON numerical data") } } - SECTION("signed std::int32_t: INT32_MIN .. INT32_MAX") { std::vector const numbers diff --git a/tests/src/unit-cbor.cpp b/tests/src/unit-cbor.cpp index 60e2dc9e0..1691bf541 100644 --- a/tests/src/unit-cbor.cpp +++ b/tests/src/unit-cbor.cpp @@ -241,13 +241,13 @@ TEST_CASE("CBOR") const std::vector numbers { -65537, - -100000, - -1000000, - -10000000, - -100000000, - -1000000000, - -4294967296, - }; + -100000, + -1000000, + -10000000, + -100000000, + -1000000000, + -4294967296, + }; for (const auto i : numbers) { CAPTURE(i) diff --git a/tests/src/unit-constructor1.cpp b/tests/src/unit-constructor1.cpp index cc9f2c4d5..3fe847887 100644 --- a/tests/src/unit-constructor1.cpp +++ b/tests/src/unit-constructor1.cpp @@ -172,7 +172,6 @@ TEST_CASE("constructors") CHECK(j == j_reference); } - SECTION("std::multimap") { std::multimap const o {{"a", json(1)}, {"b", json(1u)}, {"c", json(2.2)}, {"d", json(false)}, {"e", json("string")}, {"f", json()}}; diff --git a/tests/src/unit-custom-base-class.cpp b/tests/src/unit-custom-base-class.cpp index 673147f90..ca916a9b9 100644 --- a/tests/src/unit-custom-base-class.cpp +++ b/tests/src/unit-custom-base-class.cpp @@ -229,7 +229,6 @@ using json_with_visitor_t = nlohmann::basic_json < visitor_adaptor >; - template void visitor_adaptor::visit(const Fnc& fnc) const { diff --git a/tests/src/unit-element_access2.cpp b/tests/src/unit-element_access2.cpp index db20a02b1..70d73f214 100644 --- a/tests/src/unit-element_access2.cpp +++ b/tests/src/unit-element_access2.cpp @@ -72,7 +72,6 @@ TEST_CASE_TEMPLATE("element access 2", Json, nlohmann::json, nlohmann::ordered_j CHECK_THROWS_WITH_AS(j.at("foo"), "[json.exception.out_of_range.403] key 'foo' not found", typename Json::out_of_range&); CHECK_THROWS_WITH_AS(j_const.at("foo"), "[json.exception.out_of_range.403] key 'foo' not found", typename Json::out_of_range&); - #ifdef JSON_HAS_CPP_17 CHECK_THROWS_WITH_AS(j.at(std::string_view("foo")), "[json.exception.out_of_range.403] key 'foo' not found", typename Json::out_of_range&); CHECK_THROWS_WITH_AS(j_const.at(std::string_view("foo")), "[json.exception.out_of_range.403] key 'foo' not found", typename Json::out_of_range&); diff --git a/tests/src/unit-iterators2.cpp b/tests/src/unit-iterators2.cpp index 72a5d9dc5..403da8ee6 100644 --- a/tests/src/unit-iterators2.cpp +++ b/tests/src/unit-iterators2.cpp @@ -873,7 +873,6 @@ TEST_CASE("iterators 2") } } - #if JSON_HAS_RANGES // JSON_HAS_CPP_20 (do not remove; see note at top of file) SECTION("ranges") diff --git a/tests/src/unit-msgpack.cpp b/tests/src/unit-msgpack.cpp index 805a152e1..fa1dac82c 100644 --- a/tests/src/unit-msgpack.cpp +++ b/tests/src/unit-msgpack.cpp @@ -479,11 +479,11 @@ TEST_CASE("MessagePack") std::vector const numbers { -32769, - -65536, - -77777, - -1048576, - -2147483648LL, - }; + -65536, + -77777, + -1048576, + -2147483648LL, + }; for (auto i : numbers) { CAPTURE(i) diff --git a/tests/src/unit-ordered_json.cpp b/tests/src/unit-ordered_json.cpp index 4e853cc3c..8a4decfd6 100644 --- a/tests/src/unit-ordered_json.cpp +++ b/tests/src/unit-ordered_json.cpp @@ -12,7 +12,6 @@ using nlohmann::json; using nlohmann::ordered_json; - TEST_CASE("ordered_json") { json j; diff --git a/tests/src/unit-ordered_map.cpp b/tests/src/unit-ordered_map.cpp index 57692c3d8..0dbd80672 100644 --- a/tests/src/unit-ordered_map.cpp +++ b/tests/src/unit-ordered_map.cpp @@ -11,7 +11,6 @@ #include using nlohmann::ordered_map; - TEST_CASE("ordered_map") { SECTION("constructor") diff --git a/tests/src/unit-regression1.cpp b/tests/src/unit-regression1.cpp index 2b6e90b30..284ebd014 100644 --- a/tests/src/unit-regression1.cpp +++ b/tests/src/unit-regression1.cpp @@ -1203,7 +1203,6 @@ TEST_CASE("regression tests 1") CHECK(j["a"] >= 3); CHECK(j["a"] > 3); - CHECK(!(j["a"] <= 4)); CHECK(!(j["a"] < 4)); CHECK(!(j["a"] >= 6)); From da92c0e3e72d6a42106b5d829f5ff2d57fb16f77 Mon Sep 17 00:00:00 2001 From: Felix Yan Date: Mon, 11 Sep 2023 03:49:38 +0800 Subject: [PATCH 03/14] Correct a typo in serve_header/README.md (#4143) --- tools/serve_header/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/serve_header/README.md b/tools/serve_header/README.md index a95ef20e2..123fd4479 100644 --- a/tools/serve_header/README.md +++ b/tools/serve_header/README.md @@ -65,7 +65,7 @@ An annotated example configuration can be found in `tools/serve_header/serve_hea `serve_header.py` was designed with the goal of supporting multiple project roots or working trees at the same time. The recommended directory structure is shown below but `serve_header.py` can work with other structures as well, including a nested hierarchy. ``` -json/ ⮜ the parent or web server root directoy +json/ ⮜ the parent or web server root directory ├── develop/ ⮜ the main git checkout │ └── ... ├── feature1/ From 5fec8034933ef434a98dfbd2551b052c56345869 Mon Sep 17 00:00:00 2001 From: HO-COOH <42881734+HO-COOH@users.noreply.github.com> Date: Thu, 14 Sep 2023 23:46:34 +0800 Subject: [PATCH 04/14] Update index.md (#4149) --- docs/mkdocs/docs/api/basic_json/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/mkdocs/docs/api/basic_json/index.md b/docs/mkdocs/docs/api/basic_json/index.md index fb2be8fef..b5bdf2fa8 100644 --- a/docs/mkdocs/docs/api/basic_json/index.md +++ b/docs/mkdocs/docs/api/basic_json/index.md @@ -13,7 +13,7 @@ template< class NumberFloatType = double, template class AllocatorType = std::allocator, template class JSONSerializer = adl_serializer, - class BinaryType = std::vector, class CustomBaseClass = void> > class basic_json; From 1ce29fa22ff4fe4f65fc54eb7108e76c95a876c6 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Sat, 23 Sep 2023 17:19:28 +0200 Subject: [PATCH 05/14] Fix CI (#4160) --- .clang-tidy | 2 + include/nlohmann/detail/input/lexer.hpp | 2 +- single_include/nlohmann/json.hpp | 44 ++++++++++++++++++- single_include/nlohmann/json_fwd.hpp | 3 ++ tests/src/fuzzer-parse_bjdata.cpp | 2 +- tests/src/fuzzer-parse_ubjson.cpp | 2 +- tests/src/unit-bjdata.cpp | 14 +++--- tests/src/unit-bson.cpp | 2 +- tests/src/unit-cbor.cpp | 16 +++---- tests/src/unit-class_parser.cpp | 10 ++--- tests/src/unit-element_access2.cpp | 4 +- tests/src/unit-json_pointer.cpp | 3 +- tests/src/unit-msgpack.cpp | 14 +++--- .../src/unit-no-mem-leak-on-adl-serialize.cpp | 6 +-- tests/src/unit-unicode1.cpp | 2 +- tests/thirdparty/fifo_map/fifo_map.hpp | 4 +- 16 files changed, 88 insertions(+), 42 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 1b0fff5ce..339360b08 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -43,8 +43,10 @@ Checks: '*, -misc-non-private-member-variables-in-classes, -modernize-concat-nested-namespaces, -modernize-type-traits, + -modernize-use-constraints, -modernize-use-nodiscard, -modernize-use-trailing-return-type, + -performance-enum-size, -readability-function-cognitive-complexity, -readability-function-size, -readability-identifier-length, diff --git a/include/nlohmann/detail/input/lexer.hpp b/include/nlohmann/detail/input/lexer.hpp index 72e995108..50fc9df59 100644 --- a/include/nlohmann/detail/input/lexer.hpp +++ b/include/nlohmann/detail/input/lexer.hpp @@ -222,7 +222,7 @@ class lexer : public lexer_base for (auto range = ranges.begin(); range != ranges.end(); ++range) { get(); - if (JSON_HEDLEY_LIKELY(*range <= current && current <= *(++range))) + if (JSON_HEDLEY_LIKELY(*range <= current && current <= *(++range))) // NOLINT(bugprone-inc-dec-in-conditions) { add(current); } diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index f44b20163..2f9a63131 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -41,6 +41,7 @@ // SPDX-License-Identifier: MIT + #include // #include @@ -53,6 +54,7 @@ // SPDX-License-Identifier: MIT + // This file contains all macro definitions affecting or depending on the ABI #ifndef JSON_SKIP_LIBRARY_VERSION_CHECK @@ -154,6 +156,7 @@ // SPDX-License-Identifier: MIT + #include // transform #include // array #include // forward_list @@ -176,6 +179,7 @@ // SPDX-License-Identifier: MIT + #include // nullptr_t #include // exception #if JSON_DIAGNOSTICS @@ -195,6 +199,7 @@ // SPDX-License-Identifier: MIT + #include // array #include // size_t #include // uint8_t @@ -210,6 +215,7 @@ // SPDX-License-Identifier: MIT + #include // declval, pair // #include // __ _____ _____ _____ @@ -221,6 +227,7 @@ // SPDX-License-Identifier: MIT + #include // #include @@ -233,6 +240,7 @@ // SPDX-License-Identifier: MIT + // #include @@ -2924,6 +2932,7 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT + // #include @@ -2998,6 +3007,7 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT + #include // size_t // #include @@ -3040,6 +3050,7 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT + #include // array #include // size_t #include // conditional, enable_if, false_type, integral_constant, is_constructible, is_integral, is_same, remove_cv, remove_reference, true_type @@ -3212,6 +3223,7 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT + #include // numeric_limits #include // false_type, is_constructible, is_integral, is_same, true_type #include // declval @@ -3227,6 +3239,7 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT + #include // random_access_iterator_tag // #include @@ -3294,6 +3307,7 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT + // #include @@ -3313,6 +3327,7 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT + // #include @@ -4130,6 +4145,7 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT + #include // strlen #include // string #include // forward @@ -4515,6 +4531,7 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT + // #include @@ -4538,6 +4555,7 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT + // #include @@ -5043,6 +5061,7 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT + #include // copy #include // begin, end #include // string @@ -5062,6 +5081,7 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT + #include // size_t #include // input_iterator_tag #include // string, to_string @@ -5782,6 +5802,7 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT + #include // uint8_t, uint64_t #include // tie #include // move @@ -5893,6 +5914,7 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT + #include // uint8_t #include // size_t #include // hash @@ -6025,6 +6047,7 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT + #include // generate_n #include // array #include // ldexp @@ -6050,6 +6073,7 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT + #include // array #include // size_t #include // strlen @@ -6544,6 +6568,7 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT + #include #include // string #include // move @@ -7275,6 +7300,7 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT + #include // array #include // localeconv #include // size_t @@ -7492,7 +7518,7 @@ class lexer : public lexer_base for (auto range = ranges.begin(); range != ranges.end(); ++range) { get(); - if (JSON_HEDLEY_LIKELY(*range <= current && current <= *(++range))) + if (JSON_HEDLEY_LIKELY(*range <= current && current <= *(++range))) // NOLINT(bugprone-inc-dec-in-conditions) { add(current); } @@ -8913,6 +8939,7 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT + #include // size_t #include // declval #include // string @@ -12064,6 +12091,7 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT + #include // isfinite #include // uint8_t #include // function @@ -12580,6 +12608,7 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT + // #include // #include @@ -12592,6 +12621,7 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT + #include // ptrdiff_t #include // numeric_limits @@ -12750,6 +12780,7 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT + #include // iterator, random_access_iterator_tag, bidirectional_iterator_tag, advance, next #include // conditional, is_const, remove_const @@ -13511,6 +13542,7 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT + #include // ptrdiff_t #include // reverse_iterator #include // declval @@ -13679,6 +13711,7 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT + #include // all_of #include // isdigit #include // errno, ERANGE @@ -14673,6 +14706,7 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT + #include #include @@ -14764,6 +14798,7 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT + #include // reverse #include // array #include // map @@ -14789,6 +14824,7 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT + #include // copy #include // size_t #include // back_inserter @@ -16757,6 +16793,7 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT + #include // reverse, remove, fill, find, none_of #include // array #include // localeconv, lconv @@ -16781,6 +16818,7 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT + #include // array #include // signbit, isfinite #include // intN_t, uintN_t @@ -18875,6 +18913,7 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT + #include // equal_to, less #include // initializer_list #include // input_iterator_tag, iterator_traits @@ -24412,6 +24451,7 @@ inline void swap(nlohmann::NLOHMANN_BASIC_JSON_TPL& j1, nlohmann::NLOHMANN_BASIC // SPDX-License-Identifier: MIT + // restore clang diagnostic settings #if defined(__clang__) #pragma clang diagnostic pop @@ -24455,6 +24495,7 @@ inline void swap(nlohmann::NLOHMANN_BASIC_JSON_TPL& j1, nlohmann::NLOHMANN_BASIC // SPDX-License-Identifier: MIT + #undef JSON_HEDLEY_ALWAYS_INLINE #undef JSON_HEDLEY_ARM_VERSION #undef JSON_HEDLEY_ARM_VERSION_CHECK @@ -24605,4 +24646,5 @@ inline void swap(nlohmann::NLOHMANN_BASIC_JSON_TPL& j1, nlohmann::NLOHMANN_BASIC #undef JSON_HEDLEY_FALL_THROUGH + #endif // INCLUDE_NLOHMANN_JSON_HPP_ diff --git a/single_include/nlohmann/json_fwd.hpp b/single_include/nlohmann/json_fwd.hpp index 4940d1e9d..98070dfc9 100644 --- a/single_include/nlohmann/json_fwd.hpp +++ b/single_include/nlohmann/json_fwd.hpp @@ -24,6 +24,8 @@ // SPDX-FileCopyrightText: 2013-2022 Niels Lohmann // SPDX-License-Identifier: MIT + + // This file contains all macro definitions affecting or depending on the ABI #ifndef JSON_SKIP_LIBRARY_VERSION_CHECK @@ -115,6 +117,7 @@ } // namespace nlohmann #endif + /*! @brief namespace for Niels Lohmann @see https://github.com/nlohmann diff --git a/tests/src/fuzzer-parse_bjdata.cpp b/tests/src/fuzzer-parse_bjdata.cpp index 7f0b1b300..ef2f8fc39 100644 --- a/tests/src/fuzzer-parse_bjdata.cpp +++ b/tests/src/fuzzer-parse_bjdata.cpp @@ -45,7 +45,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) // step 2.1: round trip without adding size annotations to container types std::vector const vec2 = json::to_bjdata(j1, false, false); - // step 2.2: round trip with adding size annotations but without adding type annonations to container types + // step 2.2: round trip with adding size annotations but without adding type annotations to container types std::vector const vec3 = json::to_bjdata(j1, true, false); // step 2.3: round trip with adding size as well as type annotations to container types diff --git a/tests/src/fuzzer-parse_ubjson.cpp b/tests/src/fuzzer-parse_ubjson.cpp index 67261deb0..d19418eb0 100644 --- a/tests/src/fuzzer-parse_ubjson.cpp +++ b/tests/src/fuzzer-parse_ubjson.cpp @@ -45,7 +45,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) // step 2.1: round trip without adding size annotations to container types std::vector const vec2 = json::to_ubjson(j1, false, false); - // step 2.2: round trip with adding size annotations but without adding type annonations to container types + // step 2.2: round trip with adding size annotations but without adding type annotations to container types std::vector const vec3 = json::to_ubjson(j1, true, false); // step 2.3: round trip with adding size as well as type annotations to container types diff --git a/tests/src/unit-bjdata.cpp b/tests/src/unit-bjdata.cpp index 1aa3c22b0..919ddf84f 100644 --- a/tests/src/unit-bjdata.cpp +++ b/tests/src/unit-bjdata.cpp @@ -339,13 +339,13 @@ TEST_CASE("BJData") std::vector const numbers { -32769, - -100000, - -1000000, - -10000000, - -100000000, - -1000000000, - -2147483647 - 1, // https://stackoverflow.com/a/29356002/266378 - }; + -100000, + -1000000, + -10000000, + -100000000, + -1000000000, + -2147483647 - 1, // https://stackoverflow.com/a/29356002/266378 + }; for (const auto i : numbers) { CAPTURE(i) diff --git a/tests/src/unit-bson.cpp b/tests/src/unit-bson.cpp index 83a385a0a..31fc2cf05 100644 --- a/tests/src/unit-bson.cpp +++ b/tests/src/unit-bson.cpp @@ -562,7 +562,7 @@ TEST_CASE("BSON") } } - SECTION("Examples from http://bsonspec.org/faq.html") + SECTION("Examples from https://bsonspec.org/faq.html") { SECTION("Example 1") { diff --git a/tests/src/unit-cbor.cpp b/tests/src/unit-cbor.cpp index 1691bf541..0bf33e13d 100644 --- a/tests/src/unit-cbor.cpp +++ b/tests/src/unit-cbor.cpp @@ -241,13 +241,13 @@ TEST_CASE("CBOR") const std::vector numbers { -65537, - -100000, - -1000000, - -10000000, - -100000000, - -1000000000, - -4294967296, - }; + -100000, + -1000000, + -10000000, + -100000000, + -1000000000, + -4294967296, + }; for (const auto i : numbers) { CAPTURE(i) @@ -1962,7 +1962,7 @@ TEST_CASE("CBOR regressions") CHECK(false); } } - catch (const json::parse_error&) + catch (const json::parse_error&) // NOLINT(bugprone-empty-catch) { // parse errors are ok, because input may be random bytes } diff --git a/tests/src/unit-class_parser.cpp b/tests/src/unit-class_parser.cpp index b8bb65406..81f04eb1d 100644 --- a/tests/src/unit-class_parser.cpp +++ b/tests/src/unit-class_parser.cpp @@ -542,13 +542,13 @@ TEST_CASE("parser class") CHECK(parser_helper("9007199254740991").get() == 9007199254740991); } - SECTION("over the edge cases") // issue #178 - Integer conversion to unsigned (incorrect handling of 64 bit integers) + SECTION("over the edge cases") // issue #178 - Integer conversion to unsigned (incorrect handling of 64-bit integers) { // While RFC8259, Section 6 specifies a preference for support // for ranges in range of IEEE 754-2008 binary64 (double precision) - // this does not accommodate 64 bit integers without loss of accuracy. - // As 64 bit integers are now widely used in software, it is desirable - // to expand support to to the full 64 bit (signed and unsigned) range + // this does not accommodate 64-bit integers without loss of accuracy. + // As 64-bit integers are now widely used in software, it is desirable + // to expand support to the full 64 bit (signed and unsigned) range // i.e. -(2**63) -> (2**64)-1. // -(2**63) ** Note: compilers see negative literals as negated positive numbers (hence the -1)) @@ -822,7 +822,7 @@ TEST_CASE("parser class") CHECK(accept_helper("9007199254740991")); } - SECTION("over the edge cases") // issue #178 - Integer conversion to unsigned (incorrect handling of 64 bit integers) + SECTION("over the edge cases") // issue #178 - Integer conversion to unsigned (incorrect handling of 64-bit integers) { // While RFC8259, Section 6 specifies a preference for support // for ranges in range of IEEE 754-2008 binary64 (double precision) diff --git a/tests/src/unit-element_access2.cpp b/tests/src/unit-element_access2.cpp index 70d73f214..ef28df4d6 100644 --- a/tests/src/unit-element_access2.cpp +++ b/tests/src/unit-element_access2.cpp @@ -1521,9 +1521,9 @@ TEST_CASE_TEMPLATE("element access 2 (additional value() tests)", Json, nlohmann CHECK(j.value("foo", cpstr) == "bar"); CHECK(j.value("foo", castr) == "bar"); CHECK(j.value("foo", str) == "bar"); - // this test is in fact different than the one below, + // this test is in fact different from the one below, // because of 0 considering const char * overloads - // where as any other number does not + // whereas any other number does not CHECK(j.value("baz", 0) == 42); CHECK(j.value("baz", 47) == 42); CHECK(j.value("baz", integer) == 42); diff --git a/tests/src/unit-json_pointer.cpp b/tests/src/unit-json_pointer.cpp index 7cb718811..a045e55f3 100644 --- a/tests/src/unit-json_pointer.cpp +++ b/tests/src/unit-json_pointer.cpp @@ -123,8 +123,7 @@ TEST_CASE("JSON pointers") CHECK(j.contains(json::json_pointer("/a~1b"))); CHECK(j.contains(json::json_pointer("/m~0n"))); - // unescaped access - // access to nonexisting values yield object creation + // unescaped access to nonexisting values yield object creation CHECK(!j.contains(json::json_pointer("/a/b"))); CHECK_NOTHROW(j[json::json_pointer("/a/b")] = 42); CHECK(j.contains(json::json_pointer("/a/b"))); diff --git a/tests/src/unit-msgpack.cpp b/tests/src/unit-msgpack.cpp index fa1dac82c..ff4a25f4f 100644 --- a/tests/src/unit-msgpack.cpp +++ b/tests/src/unit-msgpack.cpp @@ -479,11 +479,11 @@ TEST_CASE("MessagePack") std::vector const numbers { -32769, - -65536, - -77777, - -1048576, - -2147483648LL, - }; + -65536, + -77777, + -1048576, + -2147483648LL, + }; for (auto i : numbers) { CAPTURE(i) @@ -1124,7 +1124,7 @@ TEST_CASE("MessagePack") // Checking against an expected vector byte by byte is // difficult, because no assumption on the order of key/value // pairs are made. We therefore only check the prefix (type and - // size and the overall size. The rest is then handled in the + // size) and the overall size. The rest is then handled in the // roundtrip check. CHECK(result.size() == 67); // 1 type, 2 size, 16*4 content CHECK(result[0] == 0xde); // map 16 @@ -1153,7 +1153,7 @@ TEST_CASE("MessagePack") // Checking against an expected vector byte by byte is // difficult, because no assumption on the order of key/value // pairs are made. We therefore only check the prefix (type and - // size and the overall size. The rest is then handled in the + // size) and the overall size. The rest is then handled in the // roundtrip check. CHECK(result.size() == 458757); // 1 type, 4 size, 65536*7 content CHECK(result[0] == 0xdf); // map 32 diff --git a/tests/src/unit-no-mem-leak-on-adl-serialize.cpp b/tests/src/unit-no-mem-leak-on-adl-serialize.cpp index a85592a83..5db7d1b1b 100644 --- a/tests/src/unit-no-mem-leak-on-adl-serialize.cpp +++ b/tests/src/unit-no-mem-leak-on-adl-serialize.cpp @@ -51,7 +51,7 @@ TEST_CASE("check_for_mem_leak_on_adl_to_json-1") const nlohmann::json j = Foo {1, 0}; std::cout << j.dump() << "\n"; } - catch (...) + catch (...) // NOLINT(bugprone-empty-catch) { // just ignore the exception in this POC } @@ -64,7 +64,7 @@ TEST_CASE("check_for_mem_leak_on_adl_to_json-2") const nlohmann::json j = Foo {1, 1}; std::cout << j.dump() << "\n"; } - catch (...) + catch (...) // NOLINT(bugprone-empty-catch) { // just ignore the exception in this POC } @@ -77,7 +77,7 @@ TEST_CASE("check_for_mem_leak_on_adl_to_json-2") const nlohmann::json j = Foo {1, 2}; std::cout << j.dump() << "\n"; } - catch (...) + catch (...) // NOLINT(bugprone-empty-catch) { // just ignore the exception in this POC } diff --git a/tests/src/unit-unicode1.cpp b/tests/src/unit-unicode1.cpp index 726a70d1c..8ed32a124 100644 --- a/tests/src/unit-unicode1.cpp +++ b/tests/src/unit-unicode1.cpp @@ -442,7 +442,7 @@ TEST_CASE("Markus Kuhn's UTF-8 decoder capability and stress test") SECTION("4.1 Examples of an overlong ASCII character") { - // With a safe UTF-8 decoder, all of the following five overlong + // With a safe UTF-8 decoder, all the following five overlong // representations of the ASCII character slash ("/") should be rejected // like a malformed UTF-8 sequence, for instance by substituting it with // a replacement character. If you see a slash below, you do not have a diff --git a/tests/thirdparty/fifo_map/fifo_map.hpp b/tests/thirdparty/fifo_map/fifo_map.hpp index 180d1768b..549b71bf9 100644 --- a/tests/thirdparty/fifo_map/fifo_map.hpp +++ b/tests/thirdparty/fifo_map/fifo_map.hpp @@ -393,7 +393,7 @@ template < } /// swaps the contents - void swap(fifo_map& other) + void swap(fifo_map& other) // NOLINT(cppcoreguidelines-noexcept-swap,performance-noexcept-swap) { std::swap(m_map, other.m_map); std::swap(m_compare, other.m_compare); @@ -520,7 +520,7 @@ template < namespace std // NOLINT(cert-dcl58-cpp,-warnings-as-errors) { template -inline void swap(nlohmann::fifo_map& m1, // NOLINT(cert-dcl58-cpp) +inline void swap(nlohmann::fifo_map& m1, // NOLINT(cert-dcl58-cpp,cppcoreguidelines-noexcept-swap,performance-noexcept-swap) nlohmann::fifo_map& m2) { m1.swap(m2); From aa87ab8b406889f34c337d9564d4ba04537b9a74 Mon Sep 17 00:00:00 2001 From: Ivor Wanders Date: Sat, 23 Sep 2023 11:19:50 -0400 Subject: [PATCH 06/14] Capture exceptions by const& in docs. (#4099) --- docs/examples/at__json_pointer.cpp | 12 ++++++------ docs/examples/at__json_pointer_const.cpp | 10 +++++----- docs/examples/at__keytype.c++17.cpp | 4 ++-- docs/examples/at__keytype_const.c++17.cpp | 4 ++-- docs/examples/at__object_t_key_type.cpp | 4 ++-- docs/examples/at__object_t_key_type_const.cpp | 4 ++-- docs/examples/at__size_type.cpp | 4 ++-- docs/examples/at__size_type_const.cpp | 4 ++-- docs/examples/back.cpp | 2 +- docs/examples/basic_json__InputIt_InputIt.cpp | 2 +- docs/examples/cbor_tag_handler_t.cpp | 2 +- docs/examples/contains__json_pointer.cpp | 4 ++-- docs/examples/diagnostics_extended.cpp | 2 +- docs/examples/diagnostics_standard.cpp | 2 +- docs/examples/dump.cpp | 2 +- docs/examples/error_handler_t.cpp | 2 +- docs/examples/exception.cpp | 2 +- docs/examples/get_ref.cpp | 2 +- docs/examples/invalid_iterator.cpp | 2 +- docs/examples/json_pointer.cpp | 6 +++--- .../nlohmann_define_type_intrusive_explicit.cpp | 2 +- .../nlohmann_define_type_intrusive_macro.cpp | 2 +- .../nlohmann_define_type_non_intrusive_explicit.cpp | 2 +- .../nlohmann_define_type_non_intrusive_macro.cpp | 2 +- docs/examples/object.cpp | 2 +- docs/examples/operator__ValueType.cpp | 2 +- docs/examples/other_error.cpp | 2 +- docs/examples/out_of_range.cpp | 2 +- docs/examples/parse__allow_exceptions.cpp | 2 +- docs/examples/parse_error.cpp | 2 +- docs/examples/type_error.cpp | 2 +- 31 files changed, 49 insertions(+), 49 deletions(-) diff --git a/docs/examples/at__json_pointer.cpp b/docs/examples/at__json_pointer.cpp index 9cb6cf9a2..15e91433d 100644 --- a/docs/examples/at__json_pointer.cpp +++ b/docs/examples/at__json_pointer.cpp @@ -41,7 +41,7 @@ int main() // try to use an array index with leading '0' json::reference ref = j.at("/array/01"_json_pointer); } - catch (json::parse_error& e) + catch (const json::parse_error& e) { std::cout << e.what() << '\n'; } @@ -52,7 +52,7 @@ int main() // try to use an array index that is not a number json::reference ref = j.at("/array/one"_json_pointer); } - catch (json::parse_error& e) + catch (const json::parse_error& e) { std::cout << e.what() << '\n'; } @@ -63,7 +63,7 @@ int main() // try to use an invalid array index json::reference ref = j.at("/array/4"_json_pointer); } - catch (json::out_of_range& e) + catch (const json::out_of_range& e) { std::cout << e.what() << '\n'; } @@ -74,7 +74,7 @@ int main() // try to use the array index '-' json::reference ref = j.at("/array/-"_json_pointer); } - catch (json::out_of_range& e) + catch (const json::out_of_range& e) { std::cout << e.what() << '\n'; } @@ -85,7 +85,7 @@ int main() // try to use a JSON pointer to a nonexistent object key json::const_reference ref = j.at("/foo"_json_pointer); } - catch (json::out_of_range& e) + catch (const json::out_of_range& e) { std::cout << e.what() << '\n'; } @@ -96,7 +96,7 @@ int main() // try to use a JSON pointer that cannot be resolved json::reference ref = j.at("/number/foo"_json_pointer); } - catch (json::out_of_range& e) + catch (const json::out_of_range& e) { std::cout << e.what() << '\n'; } diff --git a/docs/examples/at__json_pointer_const.cpp b/docs/examples/at__json_pointer_const.cpp index f049bd8d9..ab026e078 100644 --- a/docs/examples/at__json_pointer_const.cpp +++ b/docs/examples/at__json_pointer_const.cpp @@ -29,7 +29,7 @@ int main() // try to use an array index that is not a number json::const_reference ref = j.at("/array/one"_json_pointer); } - catch (json::parse_error& e) + catch (const json::parse_error& e) { std::cout << e.what() << '\n'; } @@ -40,7 +40,7 @@ int main() // try to use an invalid array index json::const_reference ref = j.at("/array/4"_json_pointer); } - catch (json::out_of_range& e) + catch (const json::out_of_range& e) { std::cout << e.what() << '\n'; } @@ -51,7 +51,7 @@ int main() // try to use the array index '-' json::const_reference ref = j.at("/array/-"_json_pointer); } - catch (json::out_of_range& e) + catch (const json::out_of_range& e) { std::cout << e.what() << '\n'; } @@ -62,7 +62,7 @@ int main() // try to use a JSON pointer to a nonexistent object key json::const_reference ref = j.at("/foo"_json_pointer); } - catch (json::out_of_range& e) + catch (const json::out_of_range& e) { std::cout << e.what() << '\n'; } @@ -73,7 +73,7 @@ int main() // try to use a JSON pointer that cannot be resolved json::const_reference ref = j.at("/number/foo"_json_pointer); } - catch (json::out_of_range& e) + catch (const json::out_of_range& e) { std::cout << e.what() << '\n'; } diff --git a/docs/examples/at__keytype.c++17.cpp b/docs/examples/at__keytype.c++17.cpp index e0d9b9e7b..032506acd 100644 --- a/docs/examples/at__keytype.c++17.cpp +++ b/docs/examples/at__keytype.c++17.cpp @@ -31,7 +31,7 @@ int main() json str = "I am a string"; str.at("the good"sv) = "Another string"; } - catch (json::type_error& e) + catch (const json::type_error& e) { std::cout << e.what() << '\n'; } @@ -42,7 +42,7 @@ int main() // try to write at a nonexisting key using string_view object.at("the fast"sv) = "il rapido"; } - catch (json::out_of_range& e) + catch (const json::out_of_range& e) { std::cout << e.what() << '\n'; } diff --git a/docs/examples/at__keytype_const.c++17.cpp b/docs/examples/at__keytype_const.c++17.cpp index 1f32f23a5..b08cd17b5 100644 --- a/docs/examples/at__keytype_const.c++17.cpp +++ b/docs/examples/at__keytype_const.c++17.cpp @@ -25,7 +25,7 @@ int main() const json str = "I am a string"; std::cout << str.at("the good"sv) << '\n'; } - catch (json::type_error& e) + catch (const json::type_error& e) { std::cout << e.what() << '\n'; } @@ -36,7 +36,7 @@ int main() // try to read from a nonexisting key using string_view std::cout << object.at("the fast"sv) << '\n'; } - catch (json::out_of_range) + catch (const json::out_of_range) { std::cout << "out of range" << '\n'; } diff --git a/docs/examples/at__object_t_key_type.cpp b/docs/examples/at__object_t_key_type.cpp index 3a59d1a50..e1f33ceca 100644 --- a/docs/examples/at__object_t_key_type.cpp +++ b/docs/examples/at__object_t_key_type.cpp @@ -29,7 +29,7 @@ int main() json str = "I am a string"; str.at("the good") = "Another string"; } - catch (json::type_error& e) + catch (const json::type_error& e) { std::cout << e.what() << '\n'; } @@ -40,7 +40,7 @@ int main() // try to write at a nonexisting key object.at("the fast") = "il rapido"; } - catch (json::out_of_range& e) + catch (const json::out_of_range& e) { std::cout << e.what() << '\n'; } diff --git a/docs/examples/at__object_t_key_type_const.cpp b/docs/examples/at__object_t_key_type_const.cpp index f41bab61a..b37bbd489 100644 --- a/docs/examples/at__object_t_key_type_const.cpp +++ b/docs/examples/at__object_t_key_type_const.cpp @@ -23,7 +23,7 @@ int main() const json str = "I am a string"; std::cout << str.at("the good") << '\n'; } - catch (json::type_error& e) + catch (const json::type_error& e) { std::cout << e.what() << '\n'; } @@ -34,7 +34,7 @@ int main() // try to read from a nonexisting key std::cout << object.at("the fast") << '\n'; } - catch (json::out_of_range) + catch (const json::out_of_range) { std::cout << "out of range" << '\n'; } diff --git a/docs/examples/at__size_type.cpp b/docs/examples/at__size_type.cpp index 001b51d59..6527c6b16 100644 --- a/docs/examples/at__size_type.cpp +++ b/docs/examples/at__size_type.cpp @@ -24,7 +24,7 @@ int main() json str = "I am a string"; str.at(0) = "Another string"; } - catch (json::type_error& e) + catch (const json::type_error& e) { std::cout << e.what() << '\n'; } @@ -35,7 +35,7 @@ int main() // try to write beyond the array limit array.at(5) = "sixth"; } - catch (json::out_of_range& e) + catch (const json::out_of_range& e) { std::cout << e.what() << '\n'; } diff --git a/docs/examples/at__size_type_const.cpp b/docs/examples/at__size_type_const.cpp index e2bebf7ec..2080387a3 100644 --- a/docs/examples/at__size_type_const.cpp +++ b/docs/examples/at__size_type_const.cpp @@ -18,7 +18,7 @@ int main() const json str = "I am a string"; std::cout << str.at(0) << '\n'; } - catch (json::type_error& e) + catch (const json::type_error& e) { std::cout << e.what() << '\n'; } @@ -29,7 +29,7 @@ int main() // try to read beyond the array limit std::cout << array.at(5) << '\n'; } - catch (json::out_of_range& e) + catch (const json::out_of_range& e) { std::cout << e.what() << '\n'; } diff --git a/docs/examples/back.cpp b/docs/examples/back.cpp index 1439a8218..45342db13 100644 --- a/docs/examples/back.cpp +++ b/docs/examples/back.cpp @@ -31,7 +31,7 @@ int main() json j_null; j_null.back(); } - catch (json::invalid_iterator& e) + catch (const json::invalid_iterator& e) { std::cout << e.what() << '\n'; } diff --git a/docs/examples/basic_json__InputIt_InputIt.cpp b/docs/examples/basic_json__InputIt_InputIt.cpp index ed5aff9a8..dec693c80 100644 --- a/docs/examples/basic_json__InputIt_InputIt.cpp +++ b/docs/examples/basic_json__InputIt_InputIt.cpp @@ -25,7 +25,7 @@ int main() { json j_invalid(j_number.begin() + 1, j_number.end()); } - catch (json::invalid_iterator& e) + catch (const json::invalid_iterator& e) { std::cout << e.what() << '\n'; } diff --git a/docs/examples/cbor_tag_handler_t.cpp b/docs/examples/cbor_tag_handler_t.cpp index 79052c7a0..38d168ca8 100644 --- a/docs/examples/cbor_tag_handler_t.cpp +++ b/docs/examples/cbor_tag_handler_t.cpp @@ -13,7 +13,7 @@ int main() { auto b_throw_on_tag = json::from_cbor(vec, true, true, json::cbor_tag_handler_t::error); } - catch (json::parse_error& e) + catch (const json::parse_error& e) { std::cout << e.what() << std::endl; } diff --git a/docs/examples/contains__json_pointer.cpp b/docs/examples/contains__json_pointer.cpp index f9de546b5..14d8514b4 100644 --- a/docs/examples/contains__json_pointer.cpp +++ b/docs/examples/contains__json_pointer.cpp @@ -26,7 +26,7 @@ int main() // try to use an array index with leading '0' j.contains("/array/01"_json_pointer); } - catch (json::parse_error& e) + catch (const json::parse_error& e) { std::cout << e.what() << '\n'; } @@ -36,7 +36,7 @@ int main() // try to use an array index that is not a number j.contains("/array/one"_json_pointer); } - catch (json::parse_error& e) + catch (const json::parse_error& e) { std::cout << e.what() << '\n'; } diff --git a/docs/examples/diagnostics_extended.cpp b/docs/examples/diagnostics_extended.cpp index f4c43f05e..3b9f484b7 100644 --- a/docs/examples/diagnostics_extended.cpp +++ b/docs/examples/diagnostics_extended.cpp @@ -15,7 +15,7 @@ int main() { int housenumber = j["address"]["housenumber"]; } - catch (json::exception& e) + catch (const json::exception& e) { std::cout << e.what() << '\n'; } diff --git a/docs/examples/diagnostics_standard.cpp b/docs/examples/diagnostics_standard.cpp index 575c409eb..eae61a4a7 100644 --- a/docs/examples/diagnostics_standard.cpp +++ b/docs/examples/diagnostics_standard.cpp @@ -13,7 +13,7 @@ int main() { int housenumber = j["address"]["housenumber"]; } - catch (json::exception& e) + catch (const json::exception& e) { std::cout << e.what() << '\n'; } diff --git a/docs/examples/dump.cpp b/docs/examples/dump.cpp index eb2d71f0e..009c95fd7 100644 --- a/docs/examples/dump.cpp +++ b/docs/examples/dump.cpp @@ -35,7 +35,7 @@ int main() { std::cout << j_invalid.dump() << std::endl; } - catch (json::type_error& e) + catch (const json::type_error& e) { std::cout << e.what() << std::endl; } diff --git a/docs/examples/error_handler_t.cpp b/docs/examples/error_handler_t.cpp index add3f3b2d..b4718d7e6 100644 --- a/docs/examples/error_handler_t.cpp +++ b/docs/examples/error_handler_t.cpp @@ -11,7 +11,7 @@ int main() { std::cout << j_invalid.dump() << std::endl; } - catch (json::type_error& e) + catch (const json::type_error& e) { std::cout << e.what() << std::endl; } diff --git a/docs/examples/exception.cpp b/docs/examples/exception.cpp index 82696e614..3e5a23b3c 100644 --- a/docs/examples/exception.cpp +++ b/docs/examples/exception.cpp @@ -11,7 +11,7 @@ int main() json j = {{"foo", "bar"}}; json k = j.at("non-existing"); } - catch (json::exception& e) + catch (const json::exception& e) { // output exception information std::cout << "message: " << e.what() << '\n' diff --git a/docs/examples/get_ref.cpp b/docs/examples/get_ref.cpp index ab25946bb..0183a6537 100644 --- a/docs/examples/get_ref.cpp +++ b/docs/examples/get_ref.cpp @@ -20,7 +20,7 @@ int main() { auto r3 = value.get_ref(); } - catch (json::type_error& ex) + catch (const json::type_error& ex) { std::cout << ex.what() << '\n'; } diff --git a/docs/examples/invalid_iterator.cpp b/docs/examples/invalid_iterator.cpp index 5d3e622e6..ecde12e62 100644 --- a/docs/examples/invalid_iterator.cpp +++ b/docs/examples/invalid_iterator.cpp @@ -12,7 +12,7 @@ int main() json::iterator it = j.begin(); auto k = it.key(); } - catch (json::invalid_iterator& e) + catch (const json::invalid_iterator& e) { // output exception information std::cout << "message: " << e.what() << '\n' diff --git a/docs/examples/json_pointer.cpp b/docs/examples/json_pointer.cpp index 75b971758..8705cf498 100644 --- a/docs/examples/json_pointer.cpp +++ b/docs/examples/json_pointer.cpp @@ -20,7 +20,7 @@ int main() { json::json_pointer p9("foo"); } - catch (json::parse_error& e) + catch (const json::parse_error& e) { std::cout << e.what() << '\n'; } @@ -30,7 +30,7 @@ int main() { json::json_pointer p10("/foo/~"); } - catch (json::parse_error& e) + catch (const json::parse_error& e) { std::cout << e.what() << '\n'; } @@ -40,7 +40,7 @@ int main() { json::json_pointer p11("/foo/~3"); } - catch (json::parse_error& e) + catch (const json::parse_error& e) { std::cout << e.what() << '\n'; } diff --git a/docs/examples/nlohmann_define_type_intrusive_explicit.cpp b/docs/examples/nlohmann_define_type_intrusive_explicit.cpp index f2d6812cb..de79bd37c 100644 --- a/docs/examples/nlohmann_define_type_intrusive_explicit.cpp +++ b/docs/examples/nlohmann_define_type_intrusive_explicit.cpp @@ -53,7 +53,7 @@ int main() { auto p3 = j3.template get(); } - catch (json::exception& e) + catch (const json::exception& e) { std::cout << "deserialization failed: " << e.what() << std::endl; } diff --git a/docs/examples/nlohmann_define_type_intrusive_macro.cpp b/docs/examples/nlohmann_define_type_intrusive_macro.cpp index 9c020689b..4ecd4294f 100644 --- a/docs/examples/nlohmann_define_type_intrusive_macro.cpp +++ b/docs/examples/nlohmann_define_type_intrusive_macro.cpp @@ -41,7 +41,7 @@ int main() { auto p3 = j3.template get(); } - catch (json::exception& e) + catch (const json::exception& e) { std::cout << "deserialization failed: " << e.what() << std::endl; } diff --git a/docs/examples/nlohmann_define_type_non_intrusive_explicit.cpp b/docs/examples/nlohmann_define_type_non_intrusive_explicit.cpp index b3040adc6..a31a7eb8f 100644 --- a/docs/examples/nlohmann_define_type_non_intrusive_explicit.cpp +++ b/docs/examples/nlohmann_define_type_non_intrusive_explicit.cpp @@ -46,7 +46,7 @@ int main() { auto p3 = j3.template get(); } - catch (json::exception& e) + catch (const json::exception& e) { std::cout << "deserialization failed: " << e.what() << std::endl; } diff --git a/docs/examples/nlohmann_define_type_non_intrusive_macro.cpp b/docs/examples/nlohmann_define_type_non_intrusive_macro.cpp index 2c76830d8..d11691b70 100644 --- a/docs/examples/nlohmann_define_type_non_intrusive_macro.cpp +++ b/docs/examples/nlohmann_define_type_non_intrusive_macro.cpp @@ -34,7 +34,7 @@ int main() { auto p3 = j3.template get(); } - catch (json::exception& e) + catch (const json::exception& e) { std::cout << "deserialization failed: " << e.what() << std::endl; } diff --git a/docs/examples/object.cpp b/docs/examples/object.cpp index 733b89b53..ad167d4af 100644 --- a/docs/examples/object.cpp +++ b/docs/examples/object.cpp @@ -21,7 +21,7 @@ int main() // can only create an object from a list of pairs json j_invalid_object = json::object({{ "one", 1, 2 }}); } - catch (json::type_error& e) + catch (const json::type_error& e) { std::cout << e.what() << '\n'; } diff --git a/docs/examples/operator__ValueType.cpp b/docs/examples/operator__ValueType.cpp index 66fcf310e..e8a1d349d 100644 --- a/docs/examples/operator__ValueType.cpp +++ b/docs/examples/operator__ValueType.cpp @@ -53,7 +53,7 @@ int main() { bool v1 = json_types["string"]; } - catch (json::type_error& e) + catch (const json::type_error& e) { std::cout << e.what() << '\n'; } diff --git a/docs/examples/other_error.cpp b/docs/examples/other_error.cpp index 99c4be70e..56aa8ae6b 100644 --- a/docs/examples/other_error.cpp +++ b/docs/examples/other_error.cpp @@ -21,7 +21,7 @@ int main() }])"_json; value.patch(patch); } - catch (json::other_error& e) + catch (const json::other_error& e) { // output exception information std::cout << "message: " << e.what() << '\n' diff --git a/docs/examples/out_of_range.cpp b/docs/examples/out_of_range.cpp index e7116408a..03282082d 100644 --- a/docs/examples/out_of_range.cpp +++ b/docs/examples/out_of_range.cpp @@ -11,7 +11,7 @@ int main() json j = {1, 2, 3, 4}; j.at(4) = 10; } - catch (json::out_of_range& e) + catch (const json::out_of_range& e) { // output exception information std::cout << "message: " << e.what() << '\n' diff --git a/docs/examples/parse__allow_exceptions.cpp b/docs/examples/parse__allow_exceptions.cpp index 82449a526..f396c347e 100644 --- a/docs/examples/parse__allow_exceptions.cpp +++ b/docs/examples/parse__allow_exceptions.cpp @@ -17,7 +17,7 @@ int main() { json j = json::parse(text); } - catch (json::parse_error& e) + catch (const json::parse_error& e) { std::cout << e.what() << std::endl; } diff --git a/docs/examples/parse_error.cpp b/docs/examples/parse_error.cpp index 9b27b58fa..ce15ebe22 100644 --- a/docs/examples/parse_error.cpp +++ b/docs/examples/parse_error.cpp @@ -10,7 +10,7 @@ int main() // parsing input with a syntax error json::parse("[1,2,3,]"); } - catch (json::parse_error& e) + catch (const json::parse_error& e) { // output exception information std::cout << "message: " << e.what() << '\n' diff --git a/docs/examples/type_error.cpp b/docs/examples/type_error.cpp index d4f18b180..f520f4013 100644 --- a/docs/examples/type_error.cpp +++ b/docs/examples/type_error.cpp @@ -11,7 +11,7 @@ int main() json j = "string"; j.push_back("another string"); } - catch (json::type_error& e) + catch (const json::type_error& e) { // output exception information std::cout << "message: " << e.what() << '\n' From e75b94b31e81a7a2d8b3b9f7f53b7ce6691a169b Mon Sep 17 00:00:00 2001 From: miny1233 <36765446+miny1233@users.noreply.github.com> Date: Sat, 23 Sep 2023 23:20:47 +0800 Subject: [PATCH 07/14] Update index.md (#4159) --- docs/mkdocs/docs/api/basic_json/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/mkdocs/docs/api/basic_json/index.md b/docs/mkdocs/docs/api/basic_json/index.md index b5bdf2fa8..922b9f218 100644 --- a/docs/mkdocs/docs/api/basic_json/index.md +++ b/docs/mkdocs/docs/api/basic_json/index.md @@ -14,7 +14,7 @@ template< template class AllocatorType = std::allocator, template class JSONSerializer = adl_serializer, class BinaryType = std::vector, - class CustomBaseClass = void> + class CustomBaseClass = void > class basic_json; ``` From 6e36c721f0e8ffcabbe4d6625d1b4723fd98fe21 Mon Sep 17 00:00:00 2001 From: tomalakgeretkal Date: Sat, 23 Sep 2023 16:21:40 +0100 Subject: [PATCH 08/14] Fixed init-list construction when size_type is not int (#4140) --- include/nlohmann/json.hpp | 5 ++++- single_include/nlohmann/json.hpp | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/include/nlohmann/json.hpp b/include/nlohmann/json.hpp index 210553490..29229e0f3 100644 --- a/include/nlohmann/json.hpp +++ b/include/nlohmann/json.hpp @@ -906,7 +906,10 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec bool is_an_object = std::all_of(init.begin(), init.end(), [](const detail::json_ref& element_ref) { - return element_ref->is_array() && element_ref->size() == 2 && (*element_ref)[0].is_string(); + // The cast is to ensure op[size_type] is called, bearing in mind size_type may not be int; + // (many string types can be constructed from 0 via its null-pointer guise, so we get a + // broken call to op[key_type], the wrong semantics and a 4804 warning on Windows) + return element_ref->is_array() && element_ref->size() == 2 && (*element_ref)[static_cast(0)].is_string(); }); // adjust type if type deduction is not wanted diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index 2f9a63131..e3e050fff 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -20112,7 +20112,10 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec bool is_an_object = std::all_of(init.begin(), init.end(), [](const detail::json_ref& element_ref) { - return element_ref->is_array() && element_ref->size() == 2 && (*element_ref)[0].is_string(); + // The cast is to ensure op[size_type] is called, bearing in mind size_type may not be int; + // (many string types can be constructed from 0 via its null-pointer guise, so we get a + // broken call to op[key_type], the wrong semantics and a 4804 warning on Windows) + return element_ref->is_array() && element_ref->size() == 2 && (*element_ref)[static_cast(0)].is_string(); }); // adjust type if type deduction is not wanted From bbd2e1636d04c6337fa53cdf8cb8092f3babfd8c Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Sat, 23 Sep 2023 20:16:37 +0200 Subject: [PATCH 09/14] Fix deprecation warning (#4161) --- docs/mkdocs/docs/api/operator_literal_json.md | 4 ++-- .../docs/api/operator_literal_json_pointer.md | 4 ++-- include/nlohmann/json.hpp | 21 +++++++++++++++---- single_include/nlohmann/json.hpp | 21 +++++++++++++++---- 4 files changed, 38 insertions(+), 12 deletions(-) diff --git a/docs/mkdocs/docs/api/operator_literal_json.md b/docs/mkdocs/docs/api/operator_literal_json.md index cda00215c..bc2b2cfc5 100644 --- a/docs/mkdocs/docs/api/operator_literal_json.md +++ b/docs/mkdocs/docs/api/operator_literal_json.md @@ -1,7 +1,7 @@ # nlohmann::operator""_json ```cpp -json operator "" _json(const char* s, std::size_t n); +json operator ""_json(const char* s, std::size_t n); ``` This operator implements a user-defined string literal for JSON objects. It can be used by adding `#!cpp _json` to a @@ -9,7 +9,7 @@ string literal and returns a [`json`](json.md) object if no parse error occurred It is recommended to bring the operator into scope using any of the following lines: ```cpp -using nlohmann::literals::operator "" _json; +using nlohmann::literals::operator ""_json; using namespace nlohmann::literals; using namespace nlohmann::json_literals; using namespace nlohmann::literals::json_literals; diff --git a/docs/mkdocs/docs/api/operator_literal_json_pointer.md b/docs/mkdocs/docs/api/operator_literal_json_pointer.md index 14d5378bc..0e12440e1 100644 --- a/docs/mkdocs/docs/api/operator_literal_json_pointer.md +++ b/docs/mkdocs/docs/api/operator_literal_json_pointer.md @@ -1,7 +1,7 @@ # nlohmann::operator""_json_pointer ```cpp -json_pointer operator "" _json_pointer(const char* s, std::size_t n); +json_pointer operator ""_json_pointer(const char* s, std::size_t n); ``` This operator implements a user-defined string literal for JSON Pointers. It can be used by adding `#!cpp _json_pointer` @@ -9,7 +9,7 @@ to a string literal and returns a [`json_pointer`](json_pointer/index.md) object It is recommended to bring the operator into scope using any of the following lines: ```cpp -using nlohmann::literals::operator "" _json_pointer; +using nlohmann::literals::operator ""_json_pointer; using namespace nlohmann::literals; using namespace nlohmann::json_literals; using namespace nlohmann::literals::json_literals; diff --git a/include/nlohmann/json.hpp b/include/nlohmann/json.hpp index 29229e0f3..b2cf861c7 100644 --- a/include/nlohmann/json.hpp +++ b/include/nlohmann/json.hpp @@ -5162,7 +5162,11 @@ inline namespace json_literals /// @brief user-defined string literal for JSON values /// @sa https://json.nlohmann.me/api/basic_json/operator_literal_json/ JSON_HEDLEY_NON_NULL(1) -inline nlohmann::json operator "" _json(const char* s, std::size_t n) +#if !defined(JSON_HEDLEY_GCC_VERSION) || JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) + inline nlohmann::json operator ""_json(const char* s, std::size_t n) +#else + inline nlohmann::json operator "" _json(const char* s, std::size_t n) +#endif { return nlohmann::json::parse(s, s + n); } @@ -5170,7 +5174,11 @@ inline nlohmann::json operator "" _json(const char* s, std::size_t n) /// @brief user-defined string literal for JSON pointer /// @sa https://json.nlohmann.me/api/basic_json/operator_literal_json_pointer/ JSON_HEDLEY_NON_NULL(1) -inline nlohmann::json::json_pointer operator "" _json_pointer(const char* s, std::size_t n) +#if !defined(JSON_HEDLEY_GCC_VERSION) || JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) + inline nlohmann::json::json_pointer operator ""_json_pointer(const char* s, std::size_t n) +#else + inline nlohmann::json::json_pointer operator "" _json_pointer(const char* s, std::size_t n) +#endif { return nlohmann::json::json_pointer(std::string(s, n)); } @@ -5234,8 +5242,13 @@ inline void swap(nlohmann::NLOHMANN_BASIC_JSON_TPL& j1, nlohmann::NLOHMANN_BASIC } // namespace std #if JSON_USE_GLOBAL_UDLS - using nlohmann::literals::json_literals::operator "" _json; // NOLINT(misc-unused-using-decls,google-global-names-in-headers) - using nlohmann::literals::json_literals::operator "" _json_pointer; //NOLINT(misc-unused-using-decls,google-global-names-in-headers) + #if !defined(JSON_HEDLEY_GCC_VERSION) || JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) + using nlohmann::literals::json_literals::operator ""_json; // NOLINT(misc-unused-using-decls,google-global-names-in-headers) + using nlohmann::literals::json_literals::operator ""_json_pointer; //NOLINT(misc-unused-using-decls,google-global-names-in-headers) + #else + using nlohmann::literals::json_literals::operator "" _json; // NOLINT(misc-unused-using-decls,google-global-names-in-headers) + using nlohmann::literals::json_literals::operator "" _json_pointer; //NOLINT(misc-unused-using-decls,google-global-names-in-headers) + #endif #endif #include diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index e3e050fff..1251cf2e6 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -24368,7 +24368,11 @@ inline namespace json_literals /// @brief user-defined string literal for JSON values /// @sa https://json.nlohmann.me/api/basic_json/operator_literal_json/ JSON_HEDLEY_NON_NULL(1) -inline nlohmann::json operator "" _json(const char* s, std::size_t n) +#if !defined(JSON_HEDLEY_GCC_VERSION) || JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) + inline nlohmann::json operator ""_json(const char* s, std::size_t n) +#else + inline nlohmann::json operator "" _json(const char* s, std::size_t n) +#endif { return nlohmann::json::parse(s, s + n); } @@ -24376,7 +24380,11 @@ inline nlohmann::json operator "" _json(const char* s, std::size_t n) /// @brief user-defined string literal for JSON pointer /// @sa https://json.nlohmann.me/api/basic_json/operator_literal_json_pointer/ JSON_HEDLEY_NON_NULL(1) -inline nlohmann::json::json_pointer operator "" _json_pointer(const char* s, std::size_t n) +#if !defined(JSON_HEDLEY_GCC_VERSION) || JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) + inline nlohmann::json::json_pointer operator ""_json_pointer(const char* s, std::size_t n) +#else + inline nlohmann::json::json_pointer operator "" _json_pointer(const char* s, std::size_t n) +#endif { return nlohmann::json::json_pointer(std::string(s, n)); } @@ -24440,8 +24448,13 @@ inline void swap(nlohmann::NLOHMANN_BASIC_JSON_TPL& j1, nlohmann::NLOHMANN_BASIC } // namespace std #if JSON_USE_GLOBAL_UDLS - using nlohmann::literals::json_literals::operator "" _json; // NOLINT(misc-unused-using-decls,google-global-names-in-headers) - using nlohmann::literals::json_literals::operator "" _json_pointer; //NOLINT(misc-unused-using-decls,google-global-names-in-headers) + #if !defined(JSON_HEDLEY_GCC_VERSION) || JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) + using nlohmann::literals::json_literals::operator ""_json; // NOLINT(misc-unused-using-decls,google-global-names-in-headers) + using nlohmann::literals::json_literals::operator ""_json_pointer; //NOLINT(misc-unused-using-decls,google-global-names-in-headers) + #else + using nlohmann::literals::json_literals::operator "" _json; // NOLINT(misc-unused-using-decls,google-global-names-in-headers) + using nlohmann::literals::json_literals::operator "" _json_pointer; //NOLINT(misc-unused-using-decls,google-global-names-in-headers) + #endif #endif // #include From 6d4b72d3c3bdc533ee706d3fa74b35199c6a186e Mon Sep 17 00:00:00 2001 From: alferov Date: Sun, 24 Sep 2023 12:23:41 +0300 Subject: [PATCH 10/14] Fix compile error with _HAS_STATIC_RTTI=0 (#4046) --- .../docs/api/macros/json_has_static_rtti.md | 31 +++++++++++++++++++ include/nlohmann/detail/macro_scope.hpp | 8 +++++ include/nlohmann/detail/macro_unscope.hpp | 1 + include/nlohmann/json.hpp | 6 ++-- single_include/nlohmann/json.hpp | 15 +++++++-- 5 files changed, 57 insertions(+), 4 deletions(-) create mode 100644 docs/mkdocs/docs/api/macros/json_has_static_rtti.md diff --git a/docs/mkdocs/docs/api/macros/json_has_static_rtti.md b/docs/mkdocs/docs/api/macros/json_has_static_rtti.md new file mode 100644 index 000000000..780878319 --- /dev/null +++ b/docs/mkdocs/docs/api/macros/json_has_static_rtti.md @@ -0,0 +1,31 @@ +# JSON_HAS_STATIC_RTTI + +```cpp +#define JSON_HAS_STATIC_RTTI /* value */ +``` + +This macro indicates whether the standard library has any support for RTTI (run time type information). +Possible values are `1` when supported or `0` when unsupported. + +## Default definition + +The default value is detected based on the preprocessor macro `#!cpp _HAS_STATIC_RTTI`. + +When the macro is not defined, the library will define it to its default value. + +## Examples + +??? example + + The code below forces the library to enable support for libraries with RTTI dependence: + + ```cpp + #define JSON_HAS_STATIC_RTTI 1 + #include + + ... + ``` + +## Version history + +- Added in version ?. diff --git a/include/nlohmann/detail/macro_scope.hpp b/include/nlohmann/detail/macro_scope.hpp index 6a463833c..faa24b586 100644 --- a/include/nlohmann/detail/macro_scope.hpp +++ b/include/nlohmann/detail/macro_scope.hpp @@ -133,6 +133,14 @@ #endif #endif +#ifndef JSON_HAS_STATIC_RTTI + #if !defined(_HAS_STATIC_RTTI) || _HAS_STATIC_RTTI != 0 + #define JSON_HAS_STATIC_RTTI 1 + #else + #define JSON_HAS_STATIC_RTTI 0 + #endif +#endif + #ifdef JSON_HAS_CPP_17 #define JSON_INLINE_VARIABLE inline #else diff --git a/include/nlohmann/detail/macro_unscope.hpp b/include/nlohmann/detail/macro_unscope.hpp index 4a871f0c2..82add9c25 100644 --- a/include/nlohmann/detail/macro_unscope.hpp +++ b/include/nlohmann/detail/macro_unscope.hpp @@ -38,6 +38,7 @@ #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM #undef JSON_HAS_THREE_WAY_COMPARISON #undef JSON_HAS_RANGES + #undef JSON_HAS_STATIC_RTTI #undef JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON #endif diff --git a/include/nlohmann/json.hpp b/include/nlohmann/json.hpp index b2cf861c7..f7fac1fb4 100644 --- a/include/nlohmann/json.hpp +++ b/include/nlohmann/json.hpp @@ -62,7 +62,9 @@ #include #if defined(JSON_HAS_CPP_17) - #include + #if JSON_HAS_STATIC_RTTI + #include + #endif #include #endif @@ -1886,7 +1888,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec #if defined(JSON_HAS_CPP_17) && (defined(__GNUC__) || (defined(_MSC_VER) && _MSC_VER >= 1910 && _MSC_VER <= 1914)) detail::negation>, #endif -#if defined(JSON_HAS_CPP_17) +#if defined(JSON_HAS_CPP_17) && JSON_HAS_STATIC_RTTI detail::negation>, #endif detail::is_detected_lazy diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index 1251cf2e6..ac4a1d08b 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -2485,6 +2485,14 @@ JSON_HEDLEY_DIAGNOSTIC_POP #endif #endif +#ifndef JSON_HAS_STATIC_RTTI + #if !defined(_HAS_STATIC_RTTI) || _HAS_STATIC_RTTI != 0 + #define JSON_HAS_STATIC_RTTI 1 + #else + #define JSON_HAS_STATIC_RTTI 0 + #endif +#endif + #ifdef JSON_HAS_CPP_17 #define JSON_INLINE_VARIABLE inline #else @@ -19268,7 +19276,9 @@ NLOHMANN_JSON_NAMESPACE_END #if defined(JSON_HAS_CPP_17) - #include + #if JSON_HAS_STATIC_RTTI + #include + #endif #include #endif @@ -21092,7 +21102,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec #if defined(JSON_HAS_CPP_17) && (defined(__GNUC__) || (defined(_MSC_VER) && _MSC_VER >= 1910 && _MSC_VER <= 1914)) detail::negation>, #endif -#if defined(JSON_HAS_CPP_17) +#if defined(JSON_HAS_CPP_17) && JSON_HAS_STATIC_RTTI detail::negation>, #endif detail::is_detected_lazy @@ -24498,6 +24508,7 @@ inline void swap(nlohmann::NLOHMANN_BASIC_JSON_TPL& j1, nlohmann::NLOHMANN_BASIC #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM #undef JSON_HAS_THREE_WAY_COMPARISON #undef JSON_HAS_RANGES + #undef JSON_HAS_STATIC_RTTI #undef JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON #endif From fac07e22c5d7dd0423ccf31c02db5603d27e6556 Mon Sep 17 00:00:00 2001 From: Craig Scott Date: Mon, 25 Sep 2023 17:31:26 +1000 Subject: [PATCH 11/14] Accept NEW CMake policies up to CMake 3.14 (#4112) Starting with CMake 3.27, deprecation warnings are issued when asking for policy settings for CMake 3.4 or earlier. The cmake_minimum_required() command accepts a version range, which allows NEW policy settings up to the upper end of that range to be used, but without raising the minimum CMake version above the bottom of that range. This means NEW policy settings will be used where available, without requiring them. This change updates the project's cmake_minimum_required() calls to use a version range to extend the upper policy version to 3.14 where it wasn't already at that version or higher. This prevents the deprecation warning from CMake 3.27, and gives breathing space before a future CMake release will start issuing similar deprecation warnings again. --- CMakeLists.txt | 2 +- tests/CMakeLists.txt | 2 +- tests/benchmarks/CMakeLists.txt | 2 +- tests/cmake_add_subdirectory/project/CMakeLists.txt | 2 +- tests/cmake_fetch_content/project/CMakeLists.txt | 2 +- tests/cmake_import/project/CMakeLists.txt | 2 +- tests/cmake_import_minver/project/CMakeLists.txt | 2 +- tests/cmake_target_include_directories/project/CMakeLists.txt | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f942e04ab..38d45b729 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.1) +cmake_minimum_required(VERSION 3.1...3.14) ## ## PROJECT diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 3b9ae4d91..a153a6924 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.13) +cmake_minimum_required(VERSION 3.13...3.14) option(JSON_Valgrind "Execute test suite with Valgrind." OFF) option(JSON_FastTests "Skip expensive/slow tests." OFF) diff --git a/tests/benchmarks/CMakeLists.txt b/tests/benchmarks/CMakeLists.txt index 92ff0ea7b..4aa095e39 100644 --- a/tests/benchmarks/CMakeLists.txt +++ b/tests/benchmarks/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.11) +cmake_minimum_required(VERSION 3.11...3.14) project(JSON_Benchmarks LANGUAGES CXX) # set compiler flags diff --git a/tests/cmake_add_subdirectory/project/CMakeLists.txt b/tests/cmake_add_subdirectory/project/CMakeLists.txt index caab6c4e1..0695305ff 100644 --- a/tests/cmake_add_subdirectory/project/CMakeLists.txt +++ b/tests/cmake_add_subdirectory/project/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.1) +cmake_minimum_required(VERSION 3.1...3.14) project(DummyImport CXX) diff --git a/tests/cmake_fetch_content/project/CMakeLists.txt b/tests/cmake_fetch_content/project/CMakeLists.txt index fd8fbdd5f..b64af9ea5 100644 --- a/tests/cmake_fetch_content/project/CMakeLists.txt +++ b/tests/cmake_fetch_content/project/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.11) +cmake_minimum_required(VERSION 3.11...3.14) project(DummyImport CXX) diff --git a/tests/cmake_import/project/CMakeLists.txt b/tests/cmake_import/project/CMakeLists.txt index fe892fc1f..585f34cef 100644 --- a/tests/cmake_import/project/CMakeLists.txt +++ b/tests/cmake_import/project/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.1) +cmake_minimum_required(VERSION 3.1...3.14) project(DummyImport CXX) diff --git a/tests/cmake_import_minver/project/CMakeLists.txt b/tests/cmake_import_minver/project/CMakeLists.txt index 29056bdc5..25e40bfac 100644 --- a/tests/cmake_import_minver/project/CMakeLists.txt +++ b/tests/cmake_import_minver/project/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.1) +cmake_minimum_required(VERSION 3.1...3.14) project(DummyImportMinVer CXX) diff --git a/tests/cmake_target_include_directories/project/CMakeLists.txt b/tests/cmake_target_include_directories/project/CMakeLists.txt index f56786c09..26b55cd89 100644 --- a/tests/cmake_target_include_directories/project/CMakeLists.txt +++ b/tests/cmake_target_include_directories/project/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.1) +cmake_minimum_required(VERSION 3.1...3.14) project(DummyImport CXX) From 35c0b3e54ce99716bf2a6bb6bdbd346f3e6d398b Mon Sep 17 00:00:00 2001 From: Vyacheslav Zhdanovskiy Date: Mon, 2 Oct 2023 14:09:53 +0300 Subject: [PATCH 12/14] Fix source highlighting in user defined type macros docs (#4169) --- .../docs/api/macros/nlohmann_define_type_intrusive.md | 8 ++++---- .../docs/api/macros/nlohmann_define_type_non_intrusive.md | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/mkdocs/docs/api/macros/nlohmann_define_type_intrusive.md b/docs/mkdocs/docs/api/macros/nlohmann_define_type_intrusive.md index afd09c6db..88df1d185 100644 --- a/docs/mkdocs/docs/api/macros/nlohmann_define_type_intrusive.md +++ b/docs/mkdocs/docs/api/macros/nlohmann_define_type_intrusive.md @@ -59,7 +59,7 @@ See examples below for the concrete generated code. Consider the following complete example: - ```cpp hl_lines="21" + ```cpp hl_lines="22" --8<-- "examples/nlohmann_define_type_intrusive_macro.cpp" ``` @@ -80,7 +80,7 @@ See examples below for the concrete generated code. The macro is equivalent to: - ```cpp hl_lines="21 22 23 24 25 26 27 28 29 30 31 32 33" + ```cpp hl_lines="22 23 24 25 26 27 28 29 30 31 32 33 34" --8<-- "examples/nlohmann_define_type_intrusive_explicit.cpp" ``` @@ -88,7 +88,7 @@ See examples below for the concrete generated code. Consider the following complete example: - ```cpp hl_lines="21" + ```cpp hl_lines="22" --8<-- "examples/nlohmann_define_type_intrusive_with_default_macro.cpp" ``` @@ -108,7 +108,7 @@ See examples below for the concrete generated code. The macro is equivalent to: - ```cpp hl_lines="21 22 23 24 25 26 27 28 29 30 31 32 33 34" + ```cpp hl_lines="21 22 23 24 25 26 27 28 29 30 31 32 33 34 35" --8<-- "examples/nlohmann_define_type_intrusive_with_default_explicit.cpp" ``` diff --git a/docs/mkdocs/docs/api/macros/nlohmann_define_type_non_intrusive.md b/docs/mkdocs/docs/api/macros/nlohmann_define_type_non_intrusive.md index 70cf934fc..e1f1991b4 100644 --- a/docs/mkdocs/docs/api/macros/nlohmann_define_type_non_intrusive.md +++ b/docs/mkdocs/docs/api/macros/nlohmann_define_type_non_intrusive.md @@ -60,7 +60,7 @@ See examples below for the concrete generated code. Consider the following complete example: - ```cpp hl_lines="15" + ```cpp hl_lines="16" --8<-- "examples/nlohmann_define_type_non_intrusive_macro.cpp" ``` @@ -80,7 +80,7 @@ See examples below for the concrete generated code. The macro is equivalent to: - ```cpp hl_lines="15 16 17 18 19 20 21 22 23 24 25 26 27" + ```cpp hl_lines="16 17 18 19 20 21 22 23 24 25 26 27 28" --8<-- "examples/nlohmann_define_type_non_intrusive_explicit.cpp" ``` @@ -88,7 +88,7 @@ See examples below for the concrete generated code. Consider the following complete example: - ```cpp hl_lines="20" + ```cpp hl_lines="21" --8<-- "examples/nlohmann_define_type_non_intrusive_with_default_macro.cpp" ``` @@ -109,7 +109,7 @@ See examples below for the concrete generated code. The macro is equivalent to: - ```cpp hl_lines="20 21 22 23 24 25 26 27 28 29 30 31 32 33" + ```cpp hl_lines="21 22 23 24 25 26 27 28 29 30 31 32 33 34" --8<-- "examples/nlohmann_define_type_non_intrusive_with_default_explicit.cpp" ``` From 6adae02ddd34d274f6ecd2ff3b9d8a51ae9bc792 Mon Sep 17 00:00:00 2001 From: Mathieu Westphal Date: Wed, 4 Oct 2023 15:24:38 +0200 Subject: [PATCH 13/14] Fix spellcheck issue (#4173) --- include/nlohmann/detail/input/input_adapters.hpp | 2 +- single_include/nlohmann/json.hpp | 2 +- tests/abi/include/nlohmann/json_v3_10_5.hpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/nlohmann/detail/input/input_adapters.hpp b/include/nlohmann/detail/input/input_adapters.hpp index e4ae7a8dc..c4bcde2d9 100644 --- a/include/nlohmann/detail/input/input_adapters.hpp +++ b/include/nlohmann/detail/input/input_adapters.hpp @@ -292,7 +292,7 @@ struct wide_string_input_helper } }; -// Wraps another input apdater to convert wide character types into individual bytes. +// Wraps another input adapter to convert wide character types into individual bytes. template class wide_string_input_adapter { diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index ac4a1d08b..14bc07d5f 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -6368,7 +6368,7 @@ struct wide_string_input_helper } }; -// Wraps another input apdater to convert wide character types into individual bytes. +// Wraps another input adapter to convert wide character types into individual bytes. template class wide_string_input_adapter { diff --git a/tests/abi/include/nlohmann/json_v3_10_5.hpp b/tests/abi/include/nlohmann/json_v3_10_5.hpp index 87995556e..1f8cdcb50 100644 --- a/tests/abi/include/nlohmann/json_v3_10_5.hpp +++ b/tests/abi/include/nlohmann/json_v3_10_5.hpp @@ -5491,7 +5491,7 @@ struct wide_string_input_helper } }; -// Wraps another input apdater to convert wide character types into individual bytes. +// Wraps another input adapter to convert wide character types into individual bytes. template class wide_string_input_adapter { From edffad036d5a93ab5a10f72a7d835eeb0d2948f9 Mon Sep 17 00:00:00 2001 From: scribam Date: Wed, 4 Oct 2023 22:16:48 +0200 Subject: [PATCH 14/14] Fix MinGW CI (#4175) --- .github/workflows/windows.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index f4d415227..7ddd4be25 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -29,6 +29,7 @@ jobs: uses: egor-tensin/setup-mingw@v2 with: platform: ${{ matrix.architecture }} + version: 12.2.0 # https://github.com/egor-tensin/setup-mingw/issues/14 - name: Run CMake run: cmake -S . -B build -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Debug -DJSON_BuildTests=On - name: Build