Skip to content

Commit 0c9adb1

Browse files
committed
Use SFINAE instead of 'requires' clause because of cppcheck.
1 parent f68d2b1 commit 0c9adb1

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

include/nlohmann/json.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3692,10 +3692,12 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
36923692
#endif
36933693
}
36943694

3695+
// template<typename ScalarType, typename std::enable_if<
3696+
// std::is_scalar<ScalarType>::value, int>::type = 0>
36953697
/// @brief comparison: equal
36963698
/// @sa https://json.nlohmann.me/api/basic_json/operator_eq/
3697-
template <typename T>
3698-
requires detail::json_compatible_type<T, basic_json_t>::value
3699+
template <typename T,
3700+
std::enable_if<detail::json_compatible_type<T, basic_json_t>::value, int>::type = 0>
36993701
bool operator==(T rhs) const noexcept
37003702
{
37013703
return *this == basic_json(rhs);

single_include/nlohmann/json.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22912,10 +22912,12 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
2291222912
#endif
2291322913
}
2291422914

22915+
// template<typename ScalarType, typename std::enable_if<
22916+
// std::is_scalar<ScalarType>::value, int>::type = 0>
2291522917
/// @brief comparison: equal
2291622918
/// @sa https://json.nlohmann.me/api/basic_json/operator_eq/
22917-
template <typename T>
22918-
requires detail::json_compatible_type<T, basic_json_t>::value
22919+
template <typename T,
22920+
std::enable_if<detail::json_compatible_type<T, basic_json_t>::value, int>::type = 0>
2291922921
bool operator==(T rhs) const noexcept
2292022922
{
2292122923
return *this == basic_json(rhs);

0 commit comments

Comments
 (0)