Don't use concept. Causes compilation error on GCC 10
Opting out of using concept and rather defining a structure while still being able to not use SFINAE and instead `requires` expression. Compiling with C++23 on GCC 13.2.1 fails on overload resolution on calling operator== for `std::nullptr_t`. The solution for this was to simply add another overload for nullptr, on par with the equivalent `nullptr_t` constructor.
This commit is contained in:
parent
ee57287af7
commit
f68d2b1475
@ -684,10 +684,11 @@ inline constexpr bool value_in_range_of(T val)
|
||||
template<bool Value>
|
||||
using bool_constant = std::integral_constant<bool, Value>;
|
||||
|
||||
#ifdef JSON_HAS_CPP_20
|
||||
template <typename T, typename BasicJsonType>
|
||||
concept CompatibleType = !is_basic_json<uncvref_t<T>>::value && is_compatible_type<BasicJsonType, uncvref_t<T>>::value;
|
||||
#endif
|
||||
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
|
||||
|
||||
@ -3694,12 +3694,19 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
|
||||
/// @brief comparison: equal
|
||||
/// @sa https://json.nlohmann.me/api/basic_json/operator_eq/
|
||||
template <detail::CompatibleType<basic_json_t> T>
|
||||
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);
|
||||
}
|
||||
|
||||
/// @brief comparison: not equal
|
||||
/// @sa https://json.nlohmann.me/api/basic_json/operator_ne/
|
||||
bool operator!=(const_reference rhs) const noexcept
|
||||
@ -3726,9 +3733,9 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
|
||||
/// @brief comparison: 3-way
|
||||
/// @sa https://json.nlohmann.me/api/basic_json/operator_spaceship/
|
||||
template<typename ScalarType>
|
||||
requires std::is_scalar_v<ScalarType>
|
||||
std::partial_ordering operator<=>(ScalarType rhs) const noexcept // *NOPAD*
|
||||
template <typename T>
|
||||
requires detail::json_compatible_type<T, basic_json_t>::value
|
||||
std::partial_ordering operator<=>(T rhs) const noexcept // *NOPAD*
|
||||
{
|
||||
return *this <=> basic_json(rhs); // *NOPAD*
|
||||
}
|
||||
|
||||
@ -4091,10 +4091,11 @@ inline constexpr bool value_in_range_of(T val)
|
||||
template<bool Value>
|
||||
using bool_constant = std::integral_constant<bool, Value>;
|
||||
|
||||
#ifdef JSON_HAS_CPP_20
|
||||
template <typename T, typename BasicJsonType>
|
||||
concept CompatibleType = !is_basic_json<uncvref_t<T>>::value && is_compatible_type<BasicJsonType, uncvref_t<T>>::value;
|
||||
#endif
|
||||
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
|
||||
@ -22913,12 +22914,19 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
|
||||
/// @brief comparison: equal
|
||||
/// @sa https://json.nlohmann.me/api/basic_json/operator_eq/
|
||||
template <detail::CompatibleType<basic_json_t> T>
|
||||
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);
|
||||
}
|
||||
|
||||
/// @brief comparison: not equal
|
||||
/// @sa https://json.nlohmann.me/api/basic_json/operator_ne/
|
||||
bool operator!=(const_reference rhs) const noexcept
|
||||
@ -22945,9 +22953,9 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
|
||||
/// @brief comparison: 3-way
|
||||
/// @sa https://json.nlohmann.me/api/basic_json/operator_spaceship/
|
||||
template<typename ScalarType>
|
||||
requires std::is_scalar_v<ScalarType>
|
||||
std::partial_ordering operator<=>(ScalarType rhs) const noexcept // *NOPAD*
|
||||
template <typename T>
|
||||
requires detail::json_compatible_type<T, basic_json_t>::value
|
||||
std::partial_ordering operator<=>(T rhs) const noexcept // *NOPAD*
|
||||
{
|
||||
return *this <=> basic_json(rhs); // *NOPAD*
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user