diff --git a/.clang-format b/.clang-format index 571a6ec23..64ee00f45 100644 --- a/.clang-format +++ b/.clang-format @@ -78,6 +78,6 @@ SpacesInConditionalStatement: false SpacesInContainerLiterals: false SpacesInParentheses: false SpacesInSquareBrackets: false -Standard: c++11 +Standard: Latest TabWidth: 4 UseTab: Never diff --git a/include/nlohmann/detail/json_pointer.hpp b/include/nlohmann/detail/json_pointer.hpp index e3237d638..f782d4879 100644 --- a/include/nlohmann/detail/json_pointer.hpp +++ b/include/nlohmann/detail/json_pointer.hpp @@ -857,9 +857,9 @@ class json_pointer /// @brief 3-way compares two JSON pointers template - std::strong_ordering operator<= > (const json_pointer& rhs) const noexcept // *NOPAD* + std::strong_ordering operator<=>(const json_pointer& rhs) const noexcept // *NOPAD* { - return reference_tokens <= > rhs.reference_tokens; // *NOPAD* + return reference_tokens <=> rhs.reference_tokens; // *NOPAD* } #else /// @brief compares two JSON pointers for equality diff --git a/include/nlohmann/detail/value_t.hpp b/include/nlohmann/detail/value_t.hpp index 337d4d4eb..446ee5d18 100644 --- a/include/nlohmann/detail/value_t.hpp +++ b/include/nlohmann/detail/value_t.hpp @@ -77,7 +77,7 @@ Returns an ordering that is similar to Python: @since version 1.0.0 */ #if JSON_HAS_THREE_WAY_COMPARISON -inline std::partial_ordering operator<= > (const value_t lhs, const value_t rhs) noexcept // *NOPAD* +inline std::partial_ordering operator<=>(const value_t lhs, const value_t rhs) noexcept // *NOPAD* #else inline bool operator<(const value_t lhs, const value_t rhs) noexcept #endif @@ -99,7 +99,7 @@ inline bool operator<(const value_t lhs, const value_t rhs) noexcept #if JSON_HAS_THREE_WAY_COMPARISON if (l_index < order.size() && r_index < order.size()) { - return order[l_index] <= > order[r_index]; // *NOPAD* + return order[l_index] <=> order[r_index]; // *NOPAD* } return std::partial_ordering::unordered; #else @@ -114,7 +114,7 @@ inline bool operator<(const value_t lhs, const value_t rhs) noexcept #if JSON_HAS_THREE_WAY_COMPARISON && defined(__GNUC__) inline bool operator<(const value_t lhs, const value_t rhs) noexcept { - return std::is_lt(lhs <= > rhs); // *NOPAD* + return std::is_lt(lhs <=> rhs); // *NOPAD* } #endif diff --git a/include/nlohmann/json.hpp b/include/nlohmann/json.hpp index d0b55b1a8..655255373 100644 --- a/include/nlohmann/json.hpp +++ b/include/nlohmann/json.hpp @@ -3671,7 +3671,8 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe /// @brief comparison: equal /// @sa https://json.nlohmann.me/api/basic_json/operator_eq/ template - requires std::is_scalar_v bool operator==(ScalarType rhs) const noexcept + requires std::is_scalar_v + bool operator==(ScalarType rhs) const noexcept { return *this == basic_json(rhs); } @@ -3689,24 +3690,24 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe /// @brief comparison: 3-way /// @sa https://json.nlohmann.me/api/basic_json/operator_spaceship/ - std::partial_ordering operator<= > (const_reference rhs) const noexcept // *NOPAD* + std::partial_ordering operator<=>(const_reference rhs) const noexcept // *NOPAD* { const_reference lhs = *this; // default_result is used if we cannot compare values. In that case, // we compare types. - JSON_IMPLEMENT_OPERATOR(<= >, // *NOPAD* + JSON_IMPLEMENT_OPERATOR(<=>, // *NOPAD* std::partial_ordering::equivalent, std::partial_ordering::unordered, - lhs_type <= > rhs_type) // *NOPAD* + lhs_type <=> rhs_type) // *NOPAD* } /// @brief comparison: 3-way /// @sa https://json.nlohmann.me/api/basic_json/operator_spaceship/ template requires std::is_scalar_v - std::partial_ordering operator<= > (ScalarType rhs) const noexcept // *NOPAD* + std::partial_ordering operator<=>(ScalarType rhs) const noexcept // *NOPAD* { - return *this <= > basic_json(rhs); // *NOPAD* + return *this <=> basic_json(rhs); // *NOPAD* } #if JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON @@ -3728,7 +3729,8 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe /// @brief comparison: less than or equal /// @sa https://json.nlohmann.me/api/basic_json/operator_le/ template - requires std::is_scalar_v bool operator<=(ScalarType rhs) const noexcept + requires std::is_scalar_v + bool operator<=(ScalarType rhs) const noexcept { return *this <= basic_json(rhs); } @@ -3748,7 +3750,8 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe /// @brief comparison: greater than or equal /// @sa https://json.nlohmann.me/api/basic_json/operator_ge/ template - requires std::is_scalar_v bool operator>=(ScalarType rhs) const noexcept + requires std::is_scalar_v + bool operator>=(ScalarType rhs) const noexcept { return *this >= basic_json(rhs); } @@ -5117,7 +5120,7 @@ struct less<::nlohmann::detail::value_t> // do not remove the space after '<', ::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); #endif diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index 1ac7c0761..ed8a2321b 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -4263,7 +4263,7 @@ inline bool operator<(const value_t lhs, const value_t rhs) noexcept #if JSON_HAS_THREE_WAY_COMPARISON if (l_index < order.size() && r_index < order.size()) { - return order[l_index] <= > order[r_index]; // *NOPAD* + return order[l_index] <=> order[r_index]; // *NOPAD* } return std::partial_ordering::unordered; #else @@ -4278,7 +4278,7 @@ inline bool operator<(const value_t lhs, const value_t rhs) noexcept #if JSON_HAS_THREE_WAY_COMPARISON && defined(__GNUC__) inline bool operator<(const value_t lhs, const value_t rhs) noexcept { - return std::is_lt(lhs <= > rhs); // *NOPAD* + return std::is_lt(lhs <=> rhs); // *NOPAD* } #endif @@ -14444,9 +14444,9 @@ class json_pointer /// @brief 3-way compares two JSON pointers template - std::strong_ordering operator<= > (const json_pointer& rhs) const noexcept // *NOPAD* + std::strong_ordering operator<=> (const json_pointer& rhs) const noexcept // *NOPAD* { - return reference_tokens <= > rhs.reference_tokens; // *NOPAD* + return reference_tokens <=> rhs.reference_tokens; // *NOPAD* } #else /// @brief compares two JSON pointers for equality @@ -23182,24 +23182,24 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe /// @brief comparison: 3-way /// @sa https://json.nlohmann.me/api/basic_json/operator_spaceship/ - std::partial_ordering operator<= > (const_reference rhs) const noexcept // *NOPAD* + std::partial_ordering operator<=> (const_reference rhs) const noexcept // *NOPAD* { const_reference lhs = *this; // default_result is used if we cannot compare values. In that case, // we compare types. - JSON_IMPLEMENT_OPERATOR(<= >, // *NOPAD* + JSON_IMPLEMENT_OPERATOR(<=>, // *NOPAD* std::partial_ordering::equivalent, std::partial_ordering::unordered, - lhs_type <= > rhs_type) // *NOPAD* + lhs_type <=> rhs_type) // *NOPAD* } /// @brief comparison: 3-way /// @sa https://json.nlohmann.me/api/basic_json/operator_spaceship/ template requires std::is_scalar_v - std::partial_ordering operator<= > (ScalarType rhs) const noexcept // *NOPAD* + std::partial_ordering operator<=> (ScalarType rhs) const noexcept // *NOPAD* { - return *this <= > basic_json(rhs); // *NOPAD* + return *this <=> basic_json(rhs); // *NOPAD* } #if JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON @@ -24610,7 +24610,7 @@ struct less<::nlohmann::detail::value_t> // do not remove the space after '<', ::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); #endif diff --git a/single_include/nlohmann/json_fwd.hpp b/single_include/nlohmann/json_fwd.hpp index 71a88a5d8..a05393935 100644 --- a/single_include/nlohmann/json_fwd.hpp +++ b/single_include/nlohmann/json_fwd.hpp @@ -24,6 +24,8 @@ // SPDX-FileCopyrightText: 2013-2023 Niels Lohmann // SPDX-License-Identifier: MIT + + // This file contains all macro definitions affecting or depending on the ABI #ifndef JSON_SKIP_LIBRARY_VERSION_CHECK @@ -113,6 +115,7 @@ } // namespace nlohmann #endif + /*! @brief namespace for Niels Lohmann @see https://github.com/nlohmann diff --git a/tests/src/unit-comparison.cpp b/tests/src/unit-comparison.cpp index 73a136160..1b0042da2 100644 --- a/tests/src/unit-comparison.cpp +++ b/tests/src/unit-comparison.cpp @@ -175,7 +175,7 @@ TEST_CASE("lexicographical comparison operators") { CAPTURE(i) CAPTURE(j) - CHECK((j_types[i] <= > j_types[j]) == expected[i][j]); // *NOPAD* + CHECK((j_types[i] <=> j_types[j]) == expected[i][j]); // *NOPAD* } } } @@ -561,7 +561,7 @@ TEST_CASE("lexicographical comparison operators") { CAPTURE(i) CAPTURE(j) - CHECK((j_values[i] <= > j_values[j]) == expected[i][j]); // *NOPAD* + CHECK((j_values[i] <=> j_values[j]) == expected[i][j]); // *NOPAD* } } } diff --git a/tests/src/unit-json_pointer.cpp b/tests/src/unit-json_pointer.cpp index b161adc3b..420171557 100644 --- a/tests/src/unit-json_pointer.cpp +++ b/tests/src/unit-json_pointer.cpp @@ -703,7 +703,7 @@ TEST_CASE("JSON pointers") // build with C++20 // JSON_HAS_CPP_20 #if JSON_HAS_THREE_WAY_COMPARISON - CHECK((ptr1 <= > ptr2) == std::strong_ordering::less); // *NOPAD* + CHECK((ptr1 <=> ptr2) == std::strong_ordering::less); // *NOPAD* CHECK(ptr2 > ptr1); #endif }