Skip to content

Commit

Permalink
Use SFINAE instead of 'requires' clause because of cppcheck.
Browse files Browse the repository at this point in the history
  • Loading branch information
fsandhei committed Feb 29, 2024
1 parent f68d2b1 commit 0c9adb1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions include/nlohmann/json.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 4 additions & 2 deletions single_include/nlohmann/json.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 0c9adb1

Please sign in to comment.