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
|
// Useful for explictly ignore equality warnings
|
||||||
#pragma GCC diagnostic push
|
#pragma GCC diagnostic push
|
||||||
#pragma GCC diagnostic ignored "-Wfloat-equal"
|
#pragma GCC diagnostic ignored "-Wfloat-equal"
|
||||||
template <typename Ta, typename Tb>
|
template <typename ValueA, typename ValueB>
|
||||||
constexpr
|
constexpr auto
|
||||||
typename std::enable_if_t<
|
equal (ValueA const &a, ValueB const &b)
|
||||||
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
|
return a == b;
|
||||||
// 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);
|
|
||||||
}
|
}
|
||||||
#pragma GCC diagnostic pop
|
#pragma GCC diagnostic pop
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user