maths: remove duplicate equality test helpers

This commit is contained in:
Danny Robson 2019-02-03 16:38:06 +11:00
parent f41ffe339c
commit 5cdabcb583

View File

@ -50,33 +50,11 @@ namespace cruft {
// Useful for explictly ignore equality warnings
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wfloat-equal"
template <typename Ta, typename Tb>
constexpr
typename std::enable_if_t<
std::is_arithmetic<Ta>::value &&
std::is_arithmetic<Tb>::value,
bool
>
equal (const Ta &a, const Tb &b)
template <typename ValueA, typename ValueB>
constexpr auto
equal (ValueA const &a, ValueB const &b)
{
// use double not to force conversion for types with explicit bool
// operators on the result of equality
return !!(a == b);
}
//-------------------------------------------------------------------------
template <typename Ta, typename Tb>
inline
typename std::enable_if_t<
!std::is_arithmetic<Ta>::value ||
!std::is_arithmetic<Tb>::value,
bool
>
equal (const Ta &a, const Tb &b)
{
// use double not to force conversion for types with explicit bool
// operators on the result of equality
return !!(a == b);
return a == b;
}
#pragma GCC diagnostic pop