maths: remove duplicate equality test helpers
This commit is contained in:
parent
f41ffe339c
commit
5cdabcb583
30
maths.hpp
30
maths.hpp
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user