Merge 8d896613a7 into 8215dbafbd
This commit is contained in:
commit
36e2c2f255
@ -742,6 +742,13 @@ 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
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|||||||
@ -3722,9 +3722,24 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|||||||
|
|
||||||
/// @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>
|
requires detail::json_compatible_type<T, basic_json_t>::value
|
||||||
bool operator==(ScalarType rhs) const noexcept
|
bool operator==(T rhs) const noexcept
|
||||||
|
{
|
||||||
|
return *this == basic_json(rhs);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @brief comparison: not equal
|
||||||
|
/// @sa https://json.nlohmann.me/api/basic_json/operator_eq/
|
||||||
|
template <typename T>
|
||||||
|
requires detail::json_compatible_type<T, basic_json_t>::value
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
@ -3755,9 +3770,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*
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4277,6 +4277,13 @@ 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
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
@ -23721,9 +23728,24 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|||||||
|
|
||||||
/// @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>
|
requires detail::json_compatible_type<T, basic_json_t>::value
|
||||||
bool operator==(ScalarType rhs) const noexcept
|
bool operator==(T rhs) const noexcept
|
||||||
|
{
|
||||||
|
return *this == basic_json(rhs);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @brief comparison: not equal
|
||||||
|
/// @sa https://json.nlohmann.me/api/basic_json/operator_eq/
|
||||||
|
template <typename T>
|
||||||
|
requires detail::json_compatible_type<T, basic_json_t>::value
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
@ -23754,9 +23776,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