diff --git a/include/nlohmann/detail/exceptions.hpp b/include/nlohmann/detail/exceptions.hpp index 6edc81ca1..c8c0a1373 100644 --- a/include/nlohmann/detail/exceptions.hpp +++ b/include/nlohmann/detail/exceptions.hpp @@ -115,7 +115,7 @@ class exception : public std::exception } auto str = std::accumulate(tokens.rbegin(), tokens.rend(), std::string{}, - [](const std::string& a, const std::string& b) + [](const std::string & a, const std::string & b) { return concat(a, '/', detail::escape(b)); }); diff --git a/include/nlohmann/detail/iterators/iterator_traits.hpp b/include/nlohmann/detail/iterators/iterator_traits.hpp index ce5fe27a1..34a20eee8 100644 --- a/include/nlohmann/detail/iterators/iterator_traits.hpp +++ b/include/nlohmann/detail/iterators/iterator_traits.hpp @@ -43,7 +43,7 @@ struct iterator_traits template struct iterator_traits < T, enable_if_t < !std::is_pointer::value >> - : iterator_types + : iterator_types { }; diff --git a/include/nlohmann/detail/meta/is_sax.hpp b/include/nlohmann/detail/meta/is_sax.hpp index 2a7f43744..215008963 100644 --- a/include/nlohmann/detail/meta/is_sax.hpp +++ b/include/nlohmann/detail/meta/is_sax.hpp @@ -73,7 +73,7 @@ using parse_error_function_t = decltype(std::declval().parse_error( template struct is_sax { - private: + private: static_assert(is_basic_json::value, "BasicJsonType must be of type basic_json<...>"); @@ -84,7 +84,7 @@ struct is_sax using binary_t = typename BasicJsonType::binary_t; using exception_t = typename BasicJsonType::exception; - public: + public: static constexpr bool value = is_detected_exact::value && is_detected_exact::value && @@ -104,7 +104,7 @@ struct is_sax template struct is_sax_static_asserts { - private: + private: static_assert(is_basic_json::value, "BasicJsonType must be of type basic_json<...>"); @@ -115,7 +115,7 @@ struct is_sax_static_asserts using binary_t = typename BasicJsonType::binary_t; using exception_t = typename BasicJsonType::exception; - public: + public: static_assert(is_detected_exact::value, "Missing/invalid function: bool null()"); static_assert(is_detected_exact::value, diff --git a/include/nlohmann/detail/meta/type_traits.hpp b/include/nlohmann/detail/meta/type_traits.hpp index aa6054c8e..9851de430 100644 --- a/include/nlohmann/detail/meta/type_traits.hpp +++ b/include/nlohmann/detail/meta/type_traits.hpp @@ -190,7 +190,7 @@ template struct conjunction : std::true_type { }; template struct conjunction : B { }; template struct conjunction - : std::conditional(B::value), conjunction, B>::type {}; +: std::conditional(B::value), conjunction, B>::type {}; // https://en.cppreference.com/w/cpp/types/negation template struct negation : std::integral_constant < bool, !B::value > { }; @@ -203,19 +203,19 @@ struct is_default_constructible : std::is_default_constructible {}; template struct is_default_constructible> - : conjunction, is_default_constructible> {}; + : conjunction, is_default_constructible> {}; template struct is_default_constructible> - : conjunction, is_default_constructible> {}; + : conjunction, is_default_constructible> {}; template struct is_default_constructible> - : conjunction...> {}; + : conjunction...> {}; template struct is_default_constructible> - : conjunction...> {}; + : conjunction...> {}; template struct is_constructible : std::is_constructible {}; @@ -238,10 +238,10 @@ struct is_iterator_traits : std::false_type {}; template struct is_iterator_traits> { - private: + private: using traits = iterator_traits; - public: + public: static constexpr auto value = is_detected::value && is_detected::value && @@ -253,7 +253,7 @@ struct is_iterator_traits> template struct is_range { - private: + private: using t_ref = typename std::add_lvalue_reference::type; using iterator = detected_t; @@ -265,7 +265,7 @@ struct is_range static constexpr auto is_iterator_begin = is_iterator_traits>::value; - public: + public: static constexpr bool value = !std::is_same::value && !std::is_same::value && is_iterator_begin; }; @@ -307,7 +307,7 @@ struct is_compatible_object_type_impl < template struct is_compatible_object_type - : is_compatible_object_type_impl {}; + : is_compatible_object_type_impl {}; template @@ -339,8 +339,8 @@ struct is_constructible_object_type_impl < template struct is_constructible_object_type - : is_constructible_object_type_impl {}; + : is_constructible_object_type_impl {}; template struct is_compatible_string_type @@ -386,7 +386,7 @@ struct is_compatible_array_type_impl < template struct is_compatible_array_type - : is_compatible_array_type_impl {}; + : is_compatible_array_type_impl {}; template struct is_constructible_array_type_impl : std::false_type {}; @@ -396,7 +396,7 @@ struct is_constructible_array_type_impl < BasicJsonType, ConstructibleArrayType, enable_if_t::value >> - : std::true_type {}; + : std::true_type {}; template struct is_constructible_array_type_impl < @@ -415,22 +415,22 @@ is_detected::value&& !std::is_same>::value&& is_complete_type < detected_t>::value >> - { - using value_type = range_value_t; +{ + using value_type = range_value_t; - static constexpr bool value = - std::is_same::value || - has_from_json::value || - has_non_default_from_json < - BasicJsonType, - value_type >::value; - }; + static constexpr bool value = + std::is_same::value || + has_from_json::value || + has_non_default_from_json < + BasicJsonType, + value_type >::value; +}; template struct is_constructible_array_type - : is_constructible_array_type_impl {}; + : is_constructible_array_type_impl {}; template @@ -456,8 +456,8 @@ struct is_compatible_integer_type_impl < template struct is_compatible_integer_type - : is_compatible_integer_type_impl {}; + : is_compatible_integer_type_impl {}; template struct is_compatible_type_impl: std::false_type {}; @@ -473,7 +473,7 @@ struct is_compatible_type_impl < template struct is_compatible_type - : is_compatible_type_impl {}; + : is_compatible_type_impl {}; template struct is_constructible_tuple : std::false_type {}; @@ -509,7 +509,7 @@ template struct is_comparable()(std::declval(), std::declval())), decltype(std::declval()(std::declval(), std::declval())) - >> : std::true_type {}; +>> : std::true_type {}; template using detect_is_transparent = typename T::is_transparent; diff --git a/include/nlohmann/json.hpp b/include/nlohmann/json.hpp index f2ab7e003..84d41ab98 100644 --- a/include/nlohmann/json.hpp +++ b/include/nlohmann/json.hpp @@ -4701,7 +4701,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec // the valid JSON Patch operations enum class patch_operations {add, remove, replace, move, copy, test, invalid}; - const auto get_op = [](const std::string& op) + const auto get_op = [](const std::string & op) { if (op == "add") { @@ -4838,8 +4838,8 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec for (const auto& val : json_patch) { // wrapper to get a value for an operation - const auto get_value = [&val](const std::string& op, - const std::string& member, + const auto get_value = [&val](const std::string & op, + const std::string & member, bool string_type) -> basic_json & { // find value @@ -5216,14 +5216,14 @@ struct less< ::nlohmann::detail::value_t> // do not remove the space after '<', */ bool operator()(::nlohmann::detail::value_t lhs, ::nlohmann::detail::value_t rhs) const noexcept -{ + { #if JSON_HAS_THREE_WAY_COMPARISON - return std::is_lt(lhs <=> rhs); // *NOPAD* + return std::is_lt(lhs <=> rhs); // *NOPAD* #else - return ::nlohmann::detail::operator<(lhs, rhs); + return ::nlohmann::detail::operator<(lhs, rhs); #endif -} - }; + } +}; // C++20 prohibit function specialization in the std namespace. #ifndef JSON_HAS_CPP_20 diff --git a/include/nlohmann/ordered_map.hpp b/include/nlohmann/ordered_map.hpp index 1ba7b7311..5d28cdf20 100644 --- a/include/nlohmann/ordered_map.hpp +++ b/include/nlohmann/ordered_map.hpp @@ -27,333 +27,333 @@ NLOHMANN_JSON_NAMESPACE_BEGIN template , class Allocator = std::allocator>> struct ordered_map : std::vector, Allocator> - { - using key_type = Key; - using mapped_type = T; - using Container = std::vector, Allocator>; - using iterator = typename Container::iterator; - using const_iterator = typename Container::const_iterator; - using size_type = typename Container::size_type; - using value_type = typename Container::value_type; +{ + using key_type = Key; + using mapped_type = T; + using Container = std::vector, Allocator>; + using iterator = typename Container::iterator; + using const_iterator = typename Container::const_iterator; + using size_type = typename Container::size_type; + using value_type = typename Container::value_type; #ifdef JSON_HAS_CPP_14 - using key_compare = std::equal_to<>; + using key_compare = std::equal_to<>; #else - using key_compare = std::equal_to; + using key_compare = std::equal_to; #endif - // Explicit constructors instead of `using Container::Container` - // otherwise older compilers choke on it (GCC <= 5.5, xcode <= 9.4) -ordered_map() noexcept(noexcept(Container())) : Container{} {} -explicit ordered_map(const Allocator& alloc) noexcept(noexcept(Container(alloc))) : Container{alloc} {} -template -ordered_map(It first, It last, const Allocator& alloc = Allocator()) -: Container{first, last, alloc} {} -ordered_map(std::initializer_list init, const Allocator& alloc = Allocator() ) -: Container{init, alloc} {} + // Explicit constructors instead of `using Container::Container` + // otherwise older compilers choke on it (GCC <= 5.5, xcode <= 9.4) + ordered_map() noexcept(noexcept(Container())) : Container{} {} + explicit ordered_map(const Allocator& alloc) noexcept(noexcept(Container(alloc))) : Container{alloc} {} + template + ordered_map(It first, It last, const Allocator& alloc = Allocator()) + : Container{first, last, alloc} {} + ordered_map(std::initializer_list init, const Allocator& alloc = Allocator() ) + : Container{init, alloc} {} -std::pair emplace(const key_type& key, T&& t) -{ - for (auto it = this->begin(); it != this->end(); ++it) + std::pair emplace(const key_type& key, T&& t) { - if (m_compare(it->first, key)) + for (auto it = this->begin(); it != this->end(); ++it) { - return {it, false}; - } - } - Container::emplace_back(key, std::forward(t)); - return {std::prev(this->end()), true}; -} - -template::value, int> = 0> -std::pair emplace(KeyType && key, T && t) -{ - for (auto it = this->begin(); it != this->end(); ++it) - { - if (m_compare(it->first, key)) - { - return {it, false}; - } - } - Container::emplace_back(std::forward(key), std::forward(t)); - return {std::prev(this->end()), true}; -} - -T& operator[](const key_type& key) -{ - return emplace(key, T{}).first->second; -} - -template::value, int> = 0> -T & operator[](KeyType && key) -{ - return emplace(std::forward(key), T{}).first->second; -} - -const T& operator[](const key_type& key) const -{ - return at(key); -} - -template::value, int> = 0> -const T & operator[](KeyType && key) const -{ - return at(std::forward(key)); -} - -T& at(const key_type& key) -{ - for (auto it = this->begin(); it != this->end(); ++it) - { - if (m_compare(it->first, key)) - { - return it->second; - } - } - - JSON_THROW(std::out_of_range("key not found")); -} - -template::value, int> = 0> -T & at(KeyType && key) // NOLINT(cppcoreguidelines-missing-std-forward) -{ - for (auto it = this->begin(); it != this->end(); ++it) - { - if (m_compare(it->first, key)) - { - return it->second; - } - } - - JSON_THROW(std::out_of_range("key not found")); -} - -const T& at(const key_type& key) const -{ - for (auto it = this->begin(); it != this->end(); ++it) - { - if (m_compare(it->first, key)) - { - return it->second; - } - } - - JSON_THROW(std::out_of_range("key not found")); -} - -template::value, int> = 0> -const T & at(KeyType && key) const // NOLINT(cppcoreguidelines-missing-std-forward) -{ - for (auto it = this->begin(); it != this->end(); ++it) - { - if (m_compare(it->first, key)) - { - return it->second; - } - } - - JSON_THROW(std::out_of_range("key not found")); -} - -size_type erase(const key_type& key) -{ - for (auto it = this->begin(); it != this->end(); ++it) - { - if (m_compare(it->first, key)) - { - // Since we cannot move const Keys, re-construct them in place - for (auto next = it; ++next != this->end(); ++it) + if (m_compare(it->first, key)) { - it->~value_type(); // Destroy but keep allocation - new (&*it) value_type{std::move(*next)}; + return {it, false}; } - Container::pop_back(); - return 1; } + Container::emplace_back(key, std::forward(t)); + return {std::prev(this->end()), true}; } - return 0; -} -template::value, int> = 0> -size_type erase(KeyType && key) // NOLINT(cppcoreguidelines-missing-std-forward) -{ - for (auto it = this->begin(); it != this->end(); ++it) + template::value, int> = 0> + std::pair emplace(KeyType && key, T && t) { - if (m_compare(it->first, key)) + for (auto it = this->begin(); it != this->end(); ++it) { - // Since we cannot move const Keys, re-construct them in place - for (auto next = it; ++next != this->end(); ++it) + if (m_compare(it->first, key)) { - it->~value_type(); // Destroy but keep allocation - new (&*it) value_type{std::move(*next)}; + return {it, false}; } - Container::pop_back(); - return 1; } - } - return 0; -} - -iterator erase(iterator pos) -{ - return erase(pos, std::next(pos)); -} - -iterator erase(iterator first, iterator last) -{ - if (first == last) - { - return first; + Container::emplace_back(std::forward(key), std::forward(t)); + return {std::prev(this->end()), true}; } - const auto elements_affected = std::distance(first, last); - const auto offset = std::distance(Container::begin(), first); - - // This is the start situation. We need to delete elements_affected - // elements (3 in this example: e, f, g), and need to return an - // iterator past the last deleted element (h in this example). - // Note that offset is the distance from the start of the vector - // to first. We will need this later. - - // [ a, b, c, d, e, f, g, h, i, j ] - // ^ ^ - // first last - - // Since we cannot move const Keys, we re-construct them in place. - // We start at first and re-construct (viz. copy) the elements from - // the back of the vector. Example for first iteration: - - // ,--------. - // v | destroy e and re-construct with h - // [ a, b, c, d, e, f, g, h, i, j ] - // ^ ^ - // it it + elements_affected - - for (auto it = first; std::next(it, elements_affected) != Container::end(); ++it) + T& operator[](const key_type& key) { - it->~value_type(); // destroy but keep allocation - new (&*it) value_type{std::move(*std::next(it, elements_affected))}; // "move" next element to it + return emplace(key, T{}).first->second; } - // [ a, b, c, d, h, i, j, h, i, j ] - // ^ ^ - // first last - - // remove the unneeded elements at the end of the vector - Container::resize(this->size() - static_cast(elements_affected)); - - // [ a, b, c, d, h, i, j ] - // ^ ^ - // first last - - // first is now pointing past the last deleted element, but we cannot - // use this iterator, because it may have been invalidated by the - // resize call. Instead, we can return begin() + offset. - return Container::begin() + offset; -} - -size_type count(const key_type& key) const -{ - for (auto it = this->begin(); it != this->end(); ++it) + template::value, int> = 0> + T & operator[](KeyType && key) { - if (m_compare(it->first, key)) + return emplace(std::forward(key), T{}).first->second; + } + + const T& operator[](const key_type& key) const + { + return at(key); + } + + template::value, int> = 0> + const T & operator[](KeyType && key) const + { + return at(std::forward(key)); + } + + T& at(const key_type& key) + { + for (auto it = this->begin(); it != this->end(); ++it) { - return 1; + if (m_compare(it->first, key)) + { + return it->second; + } } - } - return 0; -} -template::value, int> = 0> -size_type count(KeyType && key) const // NOLINT(cppcoreguidelines-missing-std-forward) -{ - for (auto it = this->begin(); it != this->end(); ++it) + JSON_THROW(std::out_of_range("key not found")); + } + + template::value, int> = 0> + T & at(KeyType && key) // NOLINT(cppcoreguidelines-missing-std-forward) { - if (m_compare(it->first, key)) + for (auto it = this->begin(); it != this->end(); ++it) { - return 1; + if (m_compare(it->first, key)) + { + return it->second; + } } - } - return 0; -} -iterator find(const key_type& key) -{ - for (auto it = this->begin(); it != this->end(); ++it) + JSON_THROW(std::out_of_range("key not found")); + } + + const T& at(const key_type& key) const { - if (m_compare(it->first, key)) + for (auto it = this->begin(); it != this->end(); ++it) { - return it; + if (m_compare(it->first, key)) + { + return it->second; + } } - } - return Container::end(); -} -template::value, int> = 0> -iterator find(KeyType && key) // NOLINT(cppcoreguidelines-missing-std-forward) -{ - for (auto it = this->begin(); it != this->end(); ++it) + JSON_THROW(std::out_of_range("key not found")); + } + + template::value, int> = 0> + const T & at(KeyType && key) const // NOLINT(cppcoreguidelines-missing-std-forward) { - if (m_compare(it->first, key)) + for (auto it = this->begin(); it != this->end(); ++it) { - return it; + if (m_compare(it->first, key)) + { + return it->second; + } } - } - return Container::end(); -} -const_iterator find(const key_type& key) const -{ - for (auto it = this->begin(); it != this->end(); ++it) + JSON_THROW(std::out_of_range("key not found")); + } + + size_type erase(const key_type& key) { - if (m_compare(it->first, key)) + for (auto it = this->begin(); it != this->end(); ++it) { - return it; + if (m_compare(it->first, key)) + { + // Since we cannot move const Keys, re-construct them in place + for (auto next = it; ++next != this->end(); ++it) + { + it->~value_type(); // Destroy but keep allocation + new (&*it) value_type{std::move(*next)}; + } + Container::pop_back(); + return 1; + } } + return 0; } - return Container::end(); -} -std::pair insert( value_type&& value ) -{ - return emplace(value.first, std::move(value.second)); -} - -std::pair insert( const value_type& value ) -{ - for (auto it = this->begin(); it != this->end(); ++it) + template::value, int> = 0> + size_type erase(KeyType && key) // NOLINT(cppcoreguidelines-missing-std-forward) { - if (m_compare(it->first, value.first)) + for (auto it = this->begin(); it != this->end(); ++it) { - return {it, false}; + if (m_compare(it->first, key)) + { + // Since we cannot move const Keys, re-construct them in place + for (auto next = it; ++next != this->end(); ++it) + { + it->~value_type(); // Destroy but keep allocation + new (&*it) value_type{std::move(*next)}; + } + Container::pop_back(); + return 1; + } + } + return 0; + } + + iterator erase(iterator pos) + { + return erase(pos, std::next(pos)); + } + + iterator erase(iterator first, iterator last) + { + if (first == last) + { + return first; + } + + const auto elements_affected = std::distance(first, last); + const auto offset = std::distance(Container::begin(), first); + + // This is the start situation. We need to delete elements_affected + // elements (3 in this example: e, f, g), and need to return an + // iterator past the last deleted element (h in this example). + // Note that offset is the distance from the start of the vector + // to first. We will need this later. + + // [ a, b, c, d, e, f, g, h, i, j ] + // ^ ^ + // first last + + // Since we cannot move const Keys, we re-construct them in place. + // We start at first and re-construct (viz. copy) the elements from + // the back of the vector. Example for first iteration: + + // ,--------. + // v | destroy e and re-construct with h + // [ a, b, c, d, e, f, g, h, i, j ] + // ^ ^ + // it it + elements_affected + + for (auto it = first; std::next(it, elements_affected) != Container::end(); ++it) + { + it->~value_type(); // destroy but keep allocation + new (&*it) value_type{std::move(*std::next(it, elements_affected))}; // "move" next element to it + } + + // [ a, b, c, d, h, i, j, h, i, j ] + // ^ ^ + // first last + + // remove the unneeded elements at the end of the vector + Container::resize(this->size() - static_cast(elements_affected)); + + // [ a, b, c, d, h, i, j ] + // ^ ^ + // first last + + // first is now pointing past the last deleted element, but we cannot + // use this iterator, because it may have been invalidated by the + // resize call. Instead, we can return begin() + offset. + return Container::begin() + offset; + } + + size_type count(const key_type& key) const + { + for (auto it = this->begin(); it != this->end(); ++it) + { + if (m_compare(it->first, key)) + { + return 1; + } + } + return 0; + } + + template::value, int> = 0> + size_type count(KeyType && key) const // NOLINT(cppcoreguidelines-missing-std-forward) + { + for (auto it = this->begin(); it != this->end(); ++it) + { + if (m_compare(it->first, key)) + { + return 1; + } + } + return 0; + } + + iterator find(const key_type& key) + { + for (auto it = this->begin(); it != this->end(); ++it) + { + if (m_compare(it->first, key)) + { + return it; + } + } + return Container::end(); + } + + template::value, int> = 0> + iterator find(KeyType && key) // NOLINT(cppcoreguidelines-missing-std-forward) + { + for (auto it = this->begin(); it != this->end(); ++it) + { + if (m_compare(it->first, key)) + { + return it; + } + } + return Container::end(); + } + + const_iterator find(const key_type& key) const + { + for (auto it = this->begin(); it != this->end(); ++it) + { + if (m_compare(it->first, key)) + { + return it; + } + } + return Container::end(); + } + + std::pair insert( value_type&& value ) + { + return emplace(value.first, std::move(value.second)); + } + + std::pair insert( const value_type& value ) + { + for (auto it = this->begin(); it != this->end(); ++it) + { + if (m_compare(it->first, value.first)) + { + return {it, false}; + } + } + Container::push_back(value); + return {--this->end(), true}; + } + + template + using require_input_iter = typename std::enable_if::iterator_category, + std::input_iterator_tag>::value>::type; + + template> + void insert(InputIt first, InputIt last) + { + for (auto it = first; it != last; ++it) + { + insert(*it); } } - Container::push_back(value); - return {--this->end(), true}; -} - -template -using require_input_iter = typename std::enable_if::iterator_category, - std::input_iterator_tag>::value>::type; - -template> -void insert(InputIt first, InputIt last) -{ - for (auto it = first; it != last; ++it) - { - insert(*it); - } -} private: -JSON_NO_UNIQUE_ADDRESS key_compare m_compare = key_compare(); - }; + JSON_NO_UNIQUE_ADDRESS key_compare m_compare = key_compare(); +}; NLOHMANN_JSON_NAMESPACE_END diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index a3191d502..55c0cdfb8 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 @@ -2940,7 +2932,6 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT - // #include @@ -3015,7 +3006,6 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT - #include // size_t // #include @@ -3058,7 +3048,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 @@ -3231,7 +3220,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 @@ -3247,7 +3235,6 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT - #include // random_access_iterator_tag // #include @@ -3286,7 +3273,7 @@ struct iterator_traits template struct iterator_traits < T, enable_if_t < !std::is_pointer::value >> - : iterator_types + : iterator_types { }; @@ -3315,7 +3302,6 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT - // #include @@ -3335,7 +3321,6 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT - // #include @@ -3597,7 +3582,7 @@ template struct conjunction : std::true_type { }; template struct conjunction : B { }; template struct conjunction - : std::conditional(B::value), conjunction, B>::type {}; +: std::conditional(B::value), conjunction, B>::type {}; // https://en.cppreference.com/w/cpp/types/negation template struct negation : std::integral_constant < bool, !B::value > { }; @@ -3610,19 +3595,19 @@ struct is_default_constructible : std::is_default_constructible {}; template struct is_default_constructible> - : conjunction, is_default_constructible> {}; + : conjunction, is_default_constructible> {}; template struct is_default_constructible> - : conjunction, is_default_constructible> {}; + : conjunction, is_default_constructible> {}; template struct is_default_constructible> - : conjunction...> {}; + : conjunction...> {}; template struct is_default_constructible> - : conjunction...> {}; + : conjunction...> {}; template struct is_constructible : std::is_constructible {}; @@ -3645,10 +3630,10 @@ struct is_iterator_traits : std::false_type {}; template struct is_iterator_traits> { - private: + private: using traits = iterator_traits; - public: + public: static constexpr auto value = is_detected::value && is_detected::value && @@ -3660,7 +3645,7 @@ struct is_iterator_traits> template struct is_range { - private: + private: using t_ref = typename std::add_lvalue_reference::type; using iterator = detected_t; @@ -3672,7 +3657,7 @@ struct is_range static constexpr auto is_iterator_begin = is_iterator_traits>::value; - public: + public: static constexpr bool value = !std::is_same::value && !std::is_same::value && is_iterator_begin; }; @@ -3714,7 +3699,7 @@ struct is_compatible_object_type_impl < template struct is_compatible_object_type - : is_compatible_object_type_impl {}; + : is_compatible_object_type_impl {}; template @@ -3746,8 +3731,8 @@ struct is_constructible_object_type_impl < template struct is_constructible_object_type - : is_constructible_object_type_impl {}; + : is_constructible_object_type_impl {}; template struct is_compatible_string_type @@ -3793,7 +3778,7 @@ struct is_compatible_array_type_impl < template struct is_compatible_array_type - : is_compatible_array_type_impl {}; + : is_compatible_array_type_impl {}; template struct is_constructible_array_type_impl : std::false_type {}; @@ -3803,7 +3788,7 @@ struct is_constructible_array_type_impl < BasicJsonType, ConstructibleArrayType, enable_if_t::value >> - : std::true_type {}; + : std::true_type {}; template struct is_constructible_array_type_impl < @@ -3822,22 +3807,22 @@ is_detected::value&& !std::is_same>::value&& is_complete_type < detected_t>::value >> - { - using value_type = range_value_t; +{ + using value_type = range_value_t; - static constexpr bool value = - std::is_same::value || - has_from_json::value || - has_non_default_from_json < - BasicJsonType, - value_type >::value; - }; + static constexpr bool value = + std::is_same::value || + has_from_json::value || + has_non_default_from_json < + BasicJsonType, + value_type >::value; +}; template struct is_constructible_array_type - : is_constructible_array_type_impl {}; + : is_constructible_array_type_impl {}; template @@ -3863,8 +3848,8 @@ struct is_compatible_integer_type_impl < template struct is_compatible_integer_type - : is_compatible_integer_type_impl {}; + : is_compatible_integer_type_impl {}; template struct is_compatible_type_impl: std::false_type {}; @@ -3880,7 +3865,7 @@ struct is_compatible_type_impl < template struct is_compatible_type - : is_compatible_type_impl {}; + : is_compatible_type_impl {}; template struct is_constructible_tuple : std::false_type {}; @@ -3916,7 +3901,7 @@ template struct is_comparable()(std::declval(), std::declval())), decltype(std::declval()(std::declval(), std::declval())) - >> : std::true_type {}; +>> : std::true_type {}; template using detect_is_transparent = typename T::is_transparent; @@ -4158,7 +4143,6 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT - #include // strlen #include // string #include // forward @@ -4389,7 +4373,7 @@ class exception : public std::exception } auto str = std::accumulate(tokens.rbegin(), tokens.rend(), std::string{}, - [](const std::string& a, const std::string& b) + [](const std::string & a, const std::string & b) { return concat(a, '/', detail::escape(b)); }); @@ -4544,7 +4528,6 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT - // #include @@ -4568,7 +4551,6 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT - // #include @@ -5074,7 +5056,6 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT - #include // copy #include // begin, end #include // string @@ -5094,7 +5075,6 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT - #include // size_t #include // input_iterator_tag #include // string, to_string @@ -5815,7 +5795,6 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT - #include // uint8_t, uint64_t #include // tie #include // move @@ -5927,7 +5906,6 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT - #include // uint8_t #include // size_t #include // hash @@ -6060,7 +6038,6 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT - #include // generate_n #include // array #include // ldexp @@ -6086,7 +6063,6 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT - #include // array #include // size_t #include // strlen @@ -6581,7 +6557,6 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT - #include #include // string #include // move @@ -7313,7 +7288,6 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT - #include // array #include // localeconv #include // size_t @@ -8952,7 +8926,6 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT - #include // size_t #include // declval #include // string @@ -9021,7 +8994,7 @@ using parse_error_function_t = decltype(std::declval().parse_error( template struct is_sax { - private: + private: static_assert(is_basic_json::value, "BasicJsonType must be of type basic_json<...>"); @@ -9032,7 +9005,7 @@ struct is_sax using binary_t = typename BasicJsonType::binary_t; using exception_t = typename BasicJsonType::exception; - public: + public: static constexpr bool value = is_detected_exact::value && is_detected_exact::value && @@ -9052,7 +9025,7 @@ struct is_sax template struct is_sax_static_asserts { - private: + private: static_assert(is_basic_json::value, "BasicJsonType must be of type basic_json<...>"); @@ -9063,7 +9036,7 @@ struct is_sax_static_asserts using binary_t = typename BasicJsonType::binary_t; using exception_t = typename BasicJsonType::exception; - public: + public: static_assert(is_detected_exact::value, "Missing/invalid function: bool null()"); static_assert(is_detected_exact::value, @@ -12104,7 +12077,6 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT - #include // isfinite #include // uint8_t #include // function @@ -12621,7 +12593,6 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT - // #include // #include @@ -12634,7 +12605,6 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT - #include // ptrdiff_t #include // numeric_limits @@ -12793,7 +12763,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 @@ -13555,7 +13524,6 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT - #include // ptrdiff_t #include // reverse_iterator #include // declval @@ -13724,7 +13692,6 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT - #include // all_of #include // isdigit #include // errno, ERANGE @@ -14719,7 +14686,6 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT - #include #include @@ -14811,7 +14777,6 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT - #include // reverse #include // array #include // map @@ -14837,7 +14802,6 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT - #include // copy #include // size_t #include // back_inserter @@ -16806,7 +16770,6 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT - #include // reverse, remove, fill, find, none_of #include // array #include // localeconv, lconv @@ -16831,7 +16794,6 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT - #include // array #include // signbit, isfinite #include // intN_t, uintN_t @@ -18926,7 +18888,6 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT - #include // equal_to, less #include // initializer_list #include // input_iterator_tag, iterator_traits @@ -18948,334 +18909,334 @@ NLOHMANN_JSON_NAMESPACE_BEGIN template , class Allocator = std::allocator>> struct ordered_map : std::vector, Allocator> - { - using key_type = Key; - using mapped_type = T; - using Container = std::vector, Allocator>; - using iterator = typename Container::iterator; - using const_iterator = typename Container::const_iterator; - using size_type = typename Container::size_type; - using value_type = typename Container::value_type; +{ + using key_type = Key; + using mapped_type = T; + using Container = std::vector, Allocator>; + using iterator = typename Container::iterator; + using const_iterator = typename Container::const_iterator; + using size_type = typename Container::size_type; + using value_type = typename Container::value_type; #ifdef JSON_HAS_CPP_14 - using key_compare = std::equal_to<>; + using key_compare = std::equal_to<>; #else - using key_compare = std::equal_to; + using key_compare = std::equal_to; #endif - // Explicit constructors instead of `using Container::Container` - // otherwise older compilers choke on it (GCC <= 5.5, xcode <= 9.4) -ordered_map() noexcept(noexcept(Container())) : Container{} {} -explicit ordered_map(const Allocator& alloc) noexcept(noexcept(Container(alloc))) : Container{alloc} {} -template -ordered_map(It first, It last, const Allocator& alloc = Allocator()) -: Container{first, last, alloc} {} -ordered_map(std::initializer_list init, const Allocator& alloc = Allocator() ) -: Container{init, alloc} {} + // Explicit constructors instead of `using Container::Container` + // otherwise older compilers choke on it (GCC <= 5.5, xcode <= 9.4) + ordered_map() noexcept(noexcept(Container())) : Container{} {} + explicit ordered_map(const Allocator& alloc) noexcept(noexcept(Container(alloc))) : Container{alloc} {} + template + ordered_map(It first, It last, const Allocator& alloc = Allocator()) + : Container{first, last, alloc} {} + ordered_map(std::initializer_list init, const Allocator& alloc = Allocator() ) + : Container{init, alloc} {} -std::pair emplace(const key_type& key, T&& t) -{ - for (auto it = this->begin(); it != this->end(); ++it) + std::pair emplace(const key_type& key, T&& t) { - if (m_compare(it->first, key)) + for (auto it = this->begin(); it != this->end(); ++it) { - return {it, false}; - } - } - Container::emplace_back(key, std::forward(t)); - return {std::prev(this->end()), true}; -} - -template::value, int> = 0> -std::pair emplace(KeyType && key, T && t) -{ - for (auto it = this->begin(); it != this->end(); ++it) - { - if (m_compare(it->first, key)) - { - return {it, false}; - } - } - Container::emplace_back(std::forward(key), std::forward(t)); - return {std::prev(this->end()), true}; -} - -T& operator[](const key_type& key) -{ - return emplace(key, T{}).first->second; -} - -template::value, int> = 0> -T & operator[](KeyType && key) -{ - return emplace(std::forward(key), T{}).first->second; -} - -const T& operator[](const key_type& key) const -{ - return at(key); -} - -template::value, int> = 0> -const T & operator[](KeyType && key) const -{ - return at(std::forward(key)); -} - -T& at(const key_type& key) -{ - for (auto it = this->begin(); it != this->end(); ++it) - { - if (m_compare(it->first, key)) - { - return it->second; - } - } - - JSON_THROW(std::out_of_range("key not found")); -} - -template::value, int> = 0> -T & at(KeyType && key) // NOLINT(cppcoreguidelines-missing-std-forward) -{ - for (auto it = this->begin(); it != this->end(); ++it) - { - if (m_compare(it->first, key)) - { - return it->second; - } - } - - JSON_THROW(std::out_of_range("key not found")); -} - -const T& at(const key_type& key) const -{ - for (auto it = this->begin(); it != this->end(); ++it) - { - if (m_compare(it->first, key)) - { - return it->second; - } - } - - JSON_THROW(std::out_of_range("key not found")); -} - -template::value, int> = 0> -const T & at(KeyType && key) const // NOLINT(cppcoreguidelines-missing-std-forward) -{ - for (auto it = this->begin(); it != this->end(); ++it) - { - if (m_compare(it->first, key)) - { - return it->second; - } - } - - JSON_THROW(std::out_of_range("key not found")); -} - -size_type erase(const key_type& key) -{ - for (auto it = this->begin(); it != this->end(); ++it) - { - if (m_compare(it->first, key)) - { - // Since we cannot move const Keys, re-construct them in place - for (auto next = it; ++next != this->end(); ++it) + if (m_compare(it->first, key)) { - it->~value_type(); // Destroy but keep allocation - new (&*it) value_type{std::move(*next)}; + return {it, false}; } - Container::pop_back(); - return 1; } + Container::emplace_back(key, std::forward(t)); + return {std::prev(this->end()), true}; } - return 0; -} -template::value, int> = 0> -size_type erase(KeyType && key) // NOLINT(cppcoreguidelines-missing-std-forward) -{ - for (auto it = this->begin(); it != this->end(); ++it) + template::value, int> = 0> + std::pair emplace(KeyType && key, T && t) { - if (m_compare(it->first, key)) + for (auto it = this->begin(); it != this->end(); ++it) { - // Since we cannot move const Keys, re-construct them in place - for (auto next = it; ++next != this->end(); ++it) + if (m_compare(it->first, key)) { - it->~value_type(); // Destroy but keep allocation - new (&*it) value_type{std::move(*next)}; + return {it, false}; } - Container::pop_back(); - return 1; } - } - return 0; -} - -iterator erase(iterator pos) -{ - return erase(pos, std::next(pos)); -} - -iterator erase(iterator first, iterator last) -{ - if (first == last) - { - return first; + Container::emplace_back(std::forward(key), std::forward(t)); + return {std::prev(this->end()), true}; } - const auto elements_affected = std::distance(first, last); - const auto offset = std::distance(Container::begin(), first); - - // This is the start situation. We need to delete elements_affected - // elements (3 in this example: e, f, g), and need to return an - // iterator past the last deleted element (h in this example). - // Note that offset is the distance from the start of the vector - // to first. We will need this later. - - // [ a, b, c, d, e, f, g, h, i, j ] - // ^ ^ - // first last - - // Since we cannot move const Keys, we re-construct them in place. - // We start at first and re-construct (viz. copy) the elements from - // the back of the vector. Example for first iteration: - - // ,--------. - // v | destroy e and re-construct with h - // [ a, b, c, d, e, f, g, h, i, j ] - // ^ ^ - // it it + elements_affected - - for (auto it = first; std::next(it, elements_affected) != Container::end(); ++it) + T& operator[](const key_type& key) { - it->~value_type(); // destroy but keep allocation - new (&*it) value_type{std::move(*std::next(it, elements_affected))}; // "move" next element to it + return emplace(key, T{}).first->second; } - // [ a, b, c, d, h, i, j, h, i, j ] - // ^ ^ - // first last - - // remove the unneeded elements at the end of the vector - Container::resize(this->size() - static_cast(elements_affected)); - - // [ a, b, c, d, h, i, j ] - // ^ ^ - // first last - - // first is now pointing past the last deleted element, but we cannot - // use this iterator, because it may have been invalidated by the - // resize call. Instead, we can return begin() + offset. - return Container::begin() + offset; -} - -size_type count(const key_type& key) const -{ - for (auto it = this->begin(); it != this->end(); ++it) + template::value, int> = 0> + T & operator[](KeyType && key) { - if (m_compare(it->first, key)) + return emplace(std::forward(key), T{}).first->second; + } + + const T& operator[](const key_type& key) const + { + return at(key); + } + + template::value, int> = 0> + const T & operator[](KeyType && key) const + { + return at(std::forward(key)); + } + + T& at(const key_type& key) + { + for (auto it = this->begin(); it != this->end(); ++it) { - return 1; + if (m_compare(it->first, key)) + { + return it->second; + } } - } - return 0; -} -template::value, int> = 0> -size_type count(KeyType && key) const // NOLINT(cppcoreguidelines-missing-std-forward) -{ - for (auto it = this->begin(); it != this->end(); ++it) + JSON_THROW(std::out_of_range("key not found")); + } + + template::value, int> = 0> + T & at(KeyType && key) // NOLINT(cppcoreguidelines-missing-std-forward) { - if (m_compare(it->first, key)) + for (auto it = this->begin(); it != this->end(); ++it) { - return 1; + if (m_compare(it->first, key)) + { + return it->second; + } } - } - return 0; -} -iterator find(const key_type& key) -{ - for (auto it = this->begin(); it != this->end(); ++it) + JSON_THROW(std::out_of_range("key not found")); + } + + const T& at(const key_type& key) const { - if (m_compare(it->first, key)) + for (auto it = this->begin(); it != this->end(); ++it) { - return it; + if (m_compare(it->first, key)) + { + return it->second; + } } - } - return Container::end(); -} -template::value, int> = 0> -iterator find(KeyType && key) // NOLINT(cppcoreguidelines-missing-std-forward) -{ - for (auto it = this->begin(); it != this->end(); ++it) + JSON_THROW(std::out_of_range("key not found")); + } + + template::value, int> = 0> + const T & at(KeyType && key) const // NOLINT(cppcoreguidelines-missing-std-forward) { - if (m_compare(it->first, key)) + for (auto it = this->begin(); it != this->end(); ++it) { - return it; + if (m_compare(it->first, key)) + { + return it->second; + } } - } - return Container::end(); -} -const_iterator find(const key_type& key) const -{ - for (auto it = this->begin(); it != this->end(); ++it) + JSON_THROW(std::out_of_range("key not found")); + } + + size_type erase(const key_type& key) { - if (m_compare(it->first, key)) + for (auto it = this->begin(); it != this->end(); ++it) { - return it; + if (m_compare(it->first, key)) + { + // Since we cannot move const Keys, re-construct them in place + for (auto next = it; ++next != this->end(); ++it) + { + it->~value_type(); // Destroy but keep allocation + new (&*it) value_type{std::move(*next)}; + } + Container::pop_back(); + return 1; + } } + return 0; } - return Container::end(); -} -std::pair insert( value_type&& value ) -{ - return emplace(value.first, std::move(value.second)); -} - -std::pair insert( const value_type& value ) -{ - for (auto it = this->begin(); it != this->end(); ++it) + template::value, int> = 0> + size_type erase(KeyType && key) // NOLINT(cppcoreguidelines-missing-std-forward) { - if (m_compare(it->first, value.first)) + for (auto it = this->begin(); it != this->end(); ++it) { - return {it, false}; + if (m_compare(it->first, key)) + { + // Since we cannot move const Keys, re-construct them in place + for (auto next = it; ++next != this->end(); ++it) + { + it->~value_type(); // Destroy but keep allocation + new (&*it) value_type{std::move(*next)}; + } + Container::pop_back(); + return 1; + } + } + return 0; + } + + iterator erase(iterator pos) + { + return erase(pos, std::next(pos)); + } + + iterator erase(iterator first, iterator last) + { + if (first == last) + { + return first; + } + + const auto elements_affected = std::distance(first, last); + const auto offset = std::distance(Container::begin(), first); + + // This is the start situation. We need to delete elements_affected + // elements (3 in this example: e, f, g), and need to return an + // iterator past the last deleted element (h in this example). + // Note that offset is the distance from the start of the vector + // to first. We will need this later. + + // [ a, b, c, d, e, f, g, h, i, j ] + // ^ ^ + // first last + + // Since we cannot move const Keys, we re-construct them in place. + // We start at first and re-construct (viz. copy) the elements from + // the back of the vector. Example for first iteration: + + // ,--------. + // v | destroy e and re-construct with h + // [ a, b, c, d, e, f, g, h, i, j ] + // ^ ^ + // it it + elements_affected + + for (auto it = first; std::next(it, elements_affected) != Container::end(); ++it) + { + it->~value_type(); // destroy but keep allocation + new (&*it) value_type{std::move(*std::next(it, elements_affected))}; // "move" next element to it + } + + // [ a, b, c, d, h, i, j, h, i, j ] + // ^ ^ + // first last + + // remove the unneeded elements at the end of the vector + Container::resize(this->size() - static_cast(elements_affected)); + + // [ a, b, c, d, h, i, j ] + // ^ ^ + // first last + + // first is now pointing past the last deleted element, but we cannot + // use this iterator, because it may have been invalidated by the + // resize call. Instead, we can return begin() + offset. + return Container::begin() + offset; + } + + size_type count(const key_type& key) const + { + for (auto it = this->begin(); it != this->end(); ++it) + { + if (m_compare(it->first, key)) + { + return 1; + } + } + return 0; + } + + template::value, int> = 0> + size_type count(KeyType && key) const // NOLINT(cppcoreguidelines-missing-std-forward) + { + for (auto it = this->begin(); it != this->end(); ++it) + { + if (m_compare(it->first, key)) + { + return 1; + } + } + return 0; + } + + iterator find(const key_type& key) + { + for (auto it = this->begin(); it != this->end(); ++it) + { + if (m_compare(it->first, key)) + { + return it; + } + } + return Container::end(); + } + + template::value, int> = 0> + iterator find(KeyType && key) // NOLINT(cppcoreguidelines-missing-std-forward) + { + for (auto it = this->begin(); it != this->end(); ++it) + { + if (m_compare(it->first, key)) + { + return it; + } + } + return Container::end(); + } + + const_iterator find(const key_type& key) const + { + for (auto it = this->begin(); it != this->end(); ++it) + { + if (m_compare(it->first, key)) + { + return it; + } + } + return Container::end(); + } + + std::pair insert( value_type&& value ) + { + return emplace(value.first, std::move(value.second)); + } + + std::pair insert( const value_type& value ) + { + for (auto it = this->begin(); it != this->end(); ++it) + { + if (m_compare(it->first, value.first)) + { + return {it, false}; + } + } + Container::push_back(value); + return {--this->end(), true}; + } + + template + using require_input_iter = typename std::enable_if::iterator_category, + std::input_iterator_tag>::value>::type; + + template> + void insert(InputIt first, InputIt last) + { + for (auto it = first; it != last; ++it) + { + insert(*it); } } - Container::push_back(value); - return {--this->end(), true}; -} - -template -using require_input_iter = typename std::enable_if::iterator_category, - std::input_iterator_tag>::value>::type; - -template> -void insert(InputIt first, InputIt last) -{ - for (auto it = first; it != last; ++it) - { - insert(*it); - } -} private: -JSON_NO_UNIQUE_ADDRESS key_compare m_compare = key_compare(); - }; + JSON_NO_UNIQUE_ADDRESS key_compare m_compare = key_compare(); +}; NLOHMANN_JSON_NAMESPACE_END @@ -23920,7 +23881,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec // the valid JSON Patch operations enum class patch_operations {add, remove, replace, move, copy, test, invalid}; - const auto get_op = [](const std::string& op) + const auto get_op = [](const std::string & op) { if (op == "add") { @@ -24057,8 +24018,8 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec for (const auto& val : json_patch) { // wrapper to get a value for an operation - const auto get_value = [&val](const std::string& op, - const std::string& member, + const auto get_value = [&val](const std::string & op, + const std::string & member, bool string_type) -> basic_json & { // find value @@ -24435,14 +24396,14 @@ struct less< ::nlohmann::detail::value_t> // do not remove the space after '<', */ bool operator()(::nlohmann::detail::value_t lhs, ::nlohmann::detail::value_t rhs) const noexcept -{ + { #if JSON_HAS_THREE_WAY_COMPARISON - return std::is_lt(lhs <=> rhs); // *NOPAD* + return std::is_lt(lhs <=> rhs); // *NOPAD* #else - return ::nlohmann::detail::operator<(lhs, rhs); + return ::nlohmann::detail::operator<(lhs, rhs); #endif -} - }; + } +}; // C++20 prohibit function specialization in the std namespace. #ifndef JSON_HAS_CPP_20 @@ -24481,7 +24442,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 @@ -24526,7 +24486,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 @@ -24677,5 +24636,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..7a0c8a82a 100644 --- a/single_include/nlohmann/json_fwd.hpp +++ b/single_include/nlohmann/json_fwd.hpp @@ -25,7 +25,6 @@ // SPDX-License-Identifier: MIT - // This file contains all macro definitions affecting or depending on the ABI #ifndef JSON_SKIP_LIBRARY_VERSION_CHECK diff --git a/tests/src/unit-regression2.cpp b/tests/src/unit-regression2.cpp index 0fd975252..dbafb436b 100644 --- a/tests/src/unit-regression2.cpp +++ b/tests/src/unit-regression2.cpp @@ -88,7 +88,7 @@ struct Data Data() = default; Data(std::string a_, std::string b_) : a(std::move(a_)) - , b(std::move(b_)) + , b(std::move(b_)) {} std::string a{}; std::string b{}; diff --git a/tests/src/unit-testsuites.cpp b/tests/src/unit-testsuites.cpp index 74413653c..e0cc127b9 100644 --- a/tests/src/unit-testsuites.cpp +++ b/tests/src/unit-testsuites.cpp @@ -106,7 +106,7 @@ TEST_CASE("compliance tests from nativejson-benchmark") SECTION("doubles") { - auto TEST_DOUBLE = [](const std::string& json_string, const double expected) + auto TEST_DOUBLE = [](const std::string & json_string, const double expected) { CAPTURE(json_string) CAPTURE(expected) @@ -238,7 +238,7 @@ TEST_CASE("compliance tests from nativejson-benchmark") SECTION("strings") { - auto TEST_STRING = [](const std::string& json_string, const std::string& expected) + auto TEST_STRING = [](const std::string & json_string, const std::string & expected) { CAPTURE(json_string) CAPTURE(expected) diff --git a/tests/src/unit-to_chars.cpp b/tests/src/unit-to_chars.cpp index c68e58ddc..d9f75ea2f 100644 --- a/tests/src/unit-to_chars.cpp +++ b/tests/src/unit-to_chars.cpp @@ -126,7 +126,7 @@ TEST_CASE("digit gen") { SECTION("single precision") { - auto check_float = [](float number, const std::string& digits, int expected_exponent) + auto check_float = [](float number, const std::string & digits, int expected_exponent) { CAPTURE(number) CAPTURE(digits) @@ -190,7 +190,7 @@ TEST_CASE("digit gen") SECTION("double precision") { - auto check_double = [](double number, const std::string& digits, int expected_exponent) + auto check_double = [](double number, const std::string & digits, int expected_exponent) { CAPTURE(number) CAPTURE(digits) @@ -336,7 +336,7 @@ TEST_CASE("formatting") { SECTION("single precision") { - auto check_float = [](float number, const std::string& expected) + auto check_float = [](float number, const std::string & expected) { std::array buf{}; char* end = nlohmann::detail::to_chars(buf.data(), buf.data() + 32, number); // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg) @@ -396,7 +396,7 @@ TEST_CASE("formatting") SECTION("double precision") { - auto check_double = [](double number, const std::string& expected) + auto check_double = [](double number, const std::string & expected) { std::array buf{}; char* end = nlohmann::detail::to_chars(buf.data(), buf.data() + 32, number); // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg) @@ -456,7 +456,7 @@ TEST_CASE("formatting") SECTION("integer") { - auto check_integer = [](std::int64_t number, const std::string& expected) + auto check_integer = [](std::int64_t number, const std::string & expected) { const nlohmann::json j = number; CHECK(j.dump() == expected);