mirror of
https://github.com/nlohmann/json.git
synced 2026-10-16 11:17:13 +00:00
Define less_general() only without three-way comparison (#5859)
less_general() (#5840) calls operator<(value_t, value_t), which exists in C++20 only for GCC. Explicit instantiation of basic_json compiles every member, so clang-cl and MSVC failed on unit-explicit_instantiation and unit-regression2 in C++20 mode. Its only caller, operator<, is defined only without three-way comparison, as it was before #5840. Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
1 parent
4da73dc5ff
commit
5683f5e024
2 files changed
+20
-20
No files matched your search
+10
-10
@@ -5518,16 +5518,6 @@ public:
|
||||
#endif
|
||||
}
|
||||
|
||||
JSON_HEDLEY_NEVER_INLINE
|
||||
static bool less_general(const_reference lhs, const_reference rhs) noexcept
|
||||
{
|
||||
// default_result is used if we cannot compare values. In that case,
|
||||
// we compare types. Note we have to call the operator explicitly,
|
||||
// because MSVC has problems otherwise.
|
||||
JSON_IMPLEMENT_OPERATOR( <, false, false, operator<(lhs_type, rhs_type),
|
||||
compare_iteratively<true>(lhs, rhs, true) == compare_result::less, false)
|
||||
}
|
||||
|
||||
#if JSON_HAS_THREE_WAY_COMPARISON
|
||||
JSON_HEDLEY_NEVER_INLINE
|
||||
static std::partial_ordering three_way_general(const_reference lhs, const_reference rhs) noexcept // *NOPAD*
|
||||
@@ -5540,6 +5530,16 @@ public:
|
||||
lhs_type <=> rhs_type, // *NOPAD*
|
||||
to_partial_ordering(compare_iteratively<true>(lhs, rhs, false)), true)
|
||||
}
|
||||
#else
|
||||
JSON_HEDLEY_NEVER_INLINE
|
||||
static bool less_general(const_reference lhs, const_reference rhs) noexcept
|
||||
{
|
||||
// default_result is used if we cannot compare values. In that case,
|
||||
// we compare types. Note we have to call the operator explicitly,
|
||||
// because MSVC has problems otherwise.
|
||||
JSON_IMPLEMENT_OPERATOR( <, false, false, operator<(lhs_type, rhs_type),
|
||||
compare_iteratively<true>(lhs, rhs, true) == compare_result::less, false)
|
||||
}
|
||||
#endif
|
||||
|
||||
/// @brief compare two leaves of the same type inside equal_structured()
|
||||
|
||||
Reference in new issue
Block a user