Merge b20332ddb9 into 0457de21cf
This commit is contained in:
commit
7793ac2fc5
@ -742,6 +742,13 @@ inline constexpr bool value_in_range_of(T val)
|
|||||||
template<bool Value>
|
template<bool Value>
|
||||||
using bool_constant = std::integral_constant<bool, Value>;
|
using bool_constant = std::integral_constant<bool, Value>;
|
||||||
|
|
||||||
|
|
||||||
|
template <typename T, typename BasicJsonType, typename U = uncvref_t<T>>
|
||||||
|
struct json_compatible_type
|
||||||
|
{
|
||||||
|
static constexpr bool value = !is_basic_json<U>::value && is_compatible_type<BasicJsonType, U>::value;
|
||||||
|
};
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// is_c_string
|
// is_c_string
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|||||||
@ -3692,11 +3692,19 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// template<typename ScalarType, typename std::enable_if<
|
||||||
|
// std::is_scalar<ScalarType>::value, int>::type = 0>
|
||||||
/// @brief comparison: equal
|
/// @brief comparison: equal
|
||||||
/// @sa https://json.nlohmann.me/api/basic_json/operator_eq/
|
/// @sa https://json.nlohmann.me/api/basic_json/operator_eq/
|
||||||
template<typename ScalarType>
|
template <typename T,
|
||||||
requires std::is_scalar_v<ScalarType>
|
std::enable_if<detail::json_compatible_type<T, basic_json_t>::value, int>::type = 0>
|
||||||
bool operator==(ScalarType rhs) const noexcept
|
bool operator==(T rhs) const noexcept
|
||||||
|
{
|
||||||
|
return *this == basic_json(rhs);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @sa https://json.nlohmann.me/api/basic_json/operator_eq/
|
||||||
|
bool operator==(std::nullptr_t rhs) const noexcept
|
||||||
{
|
{
|
||||||
return *this == basic_json(rhs);
|
return *this == basic_json(rhs);
|
||||||
}
|
}
|
||||||
@ -3727,9 +3735,9 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|||||||
|
|
||||||
/// @brief comparison: 3-way
|
/// @brief comparison: 3-way
|
||||||
/// @sa https://json.nlohmann.me/api/basic_json/operator_spaceship/
|
/// @sa https://json.nlohmann.me/api/basic_json/operator_spaceship/
|
||||||
template<typename ScalarType>
|
template <typename T>
|
||||||
requires std::is_scalar_v<ScalarType>
|
requires detail::json_compatible_type<T, basic_json_t>::value
|
||||||
std::partial_ordering operator<=>(ScalarType rhs) const noexcept // *NOPAD*
|
std::partial_ordering operator<=>(T rhs) const noexcept // *NOPAD*
|
||||||
{
|
{
|
||||||
return *this <=> basic_json(rhs); // *NOPAD*
|
return *this <=> basic_json(rhs); // *NOPAD*
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4155,6 +4155,12 @@ inline constexpr bool value_in_range_of(T val)
|
|||||||
template<bool Value>
|
template<bool Value>
|
||||||
using bool_constant = std::integral_constant<bool, Value>;
|
using bool_constant = std::integral_constant<bool, Value>;
|
||||||
|
|
||||||
|
template <typename T, typename BasicJsonType, typename U = uncvref_t<T>>
|
||||||
|
struct json_compatible_type
|
||||||
|
{
|
||||||
|
static constexpr auto value = !is_basic_json<U>::value && is_compatible_type<BasicJsonType, U>::value;
|
||||||
|
};
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// is_c_string
|
// is_c_string
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
@ -22995,11 +23001,19 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// template<typename ScalarType, typename std::enable_if<
|
||||||
|
// std::is_scalar<ScalarType>::value, int>::type = 0>
|
||||||
/// @brief comparison: equal
|
/// @brief comparison: equal
|
||||||
/// @sa https://json.nlohmann.me/api/basic_json/operator_eq/
|
/// @sa https://json.nlohmann.me/api/basic_json/operator_eq/
|
||||||
template<typename ScalarType>
|
template <typename T,
|
||||||
requires std::is_scalar_v<ScalarType>
|
std::enable_if<detail::json_compatible_type<T, basic_json_t>::value, int>::type = 0>
|
||||||
bool operator==(ScalarType rhs) const noexcept
|
bool operator==(T rhs) const noexcept
|
||||||
|
{
|
||||||
|
return *this == basic_json(rhs);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @sa https://json.nlohmann.me/api/basic_json/operator_eq/
|
||||||
|
bool operator==(std::nullptr_t rhs) const noexcept
|
||||||
{
|
{
|
||||||
return *this == basic_json(rhs);
|
return *this == basic_json(rhs);
|
||||||
}
|
}
|
||||||
@ -23030,9 +23044,9 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|||||||
|
|
||||||
/// @brief comparison: 3-way
|
/// @brief comparison: 3-way
|
||||||
/// @sa https://json.nlohmann.me/api/basic_json/operator_spaceship/
|
/// @sa https://json.nlohmann.me/api/basic_json/operator_spaceship/
|
||||||
template<typename ScalarType>
|
template <typename T>
|
||||||
requires std::is_scalar_v<ScalarType>
|
requires detail::json_compatible_type<T, basic_json_t>::value
|
||||||
std::partial_ordering operator<=>(ScalarType rhs) const noexcept // *NOPAD*
|
std::partial_ordering operator<=>(T rhs) const noexcept // *NOPAD*
|
||||||
{
|
{
|
||||||
return *this <=> basic_json(rhs); // *NOPAD*
|
return *this <=> basic_json(rhs); // *NOPAD*
|
||||||
}
|
}
|
||||||
|
|||||||
@ -357,6 +357,7 @@ TEST_CASE("lexicographical comparison operators")
|
|||||||
CAPTURE(i)
|
CAPTURE(i)
|
||||||
CAPTURE(j)
|
CAPTURE(j)
|
||||||
CHECK((j_values[i] == j_values[j]) == expected_eq[i][j]);
|
CHECK((j_values[i] == j_values[j]) == expected_eq[i][j]);
|
||||||
|
CHECK(expected_eq[i][j] == (j_values[i] == j_values[j]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user