Use SFINAE instead of 'requires' clause because of cppcheck.

This commit is contained in:
Fredrik Sandhei 2024-02-29 21:24:01 +01:00
parent f68d2b1475
commit 0c9adb13f5
2 changed files with 8 additions and 4 deletions

View File

@ -3692,10 +3692,12 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
#endif
}
// template<typename ScalarType, typename std::enable_if<
// std::is_scalar<ScalarType>::value, int>::type = 0>
/// @brief comparison: equal
/// @sa https://json.nlohmann.me/api/basic_json/operator_eq/
template <typename T>
requires detail::json_compatible_type<T, basic_json_t>::value
template <typename T,
std::enable_if<detail::json_compatible_type<T, basic_json_t>::value, int>::type = 0>
bool operator==(T rhs) const noexcept
{
return *this == basic_json(rhs);

View File

@ -22912,10 +22912,12 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
#endif
}
// template<typename ScalarType, typename std::enable_if<
// std::is_scalar<ScalarType>::value, int>::type = 0>
/// @brief comparison: equal
/// @sa https://json.nlohmann.me/api/basic_json/operator_eq/
template <typename T>
requires detail::json_compatible_type<T, basic_json_t>::value
template <typename T,
std::enable_if<detail::json_compatible_type<T, basic_json_t>::value, int>::type = 0>
bool operator==(T rhs) const noexcept
{
return *this == basic_json(rhs);