Provide a better std::enable_if<>
solution
This commit is contained in:
@@ -218,21 +218,22 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool operator ==(const Threshold<T> &rhs) const
|
||||
template<typename U = T>
|
||||
typename std::enable_if<std::is_floating_point<U>::value, bool>::type operator ==(const Threshold<U> &rhs) const
|
||||
{
|
||||
if (_isDouble) {
|
||||
return std::abs(value[0] - rhs.value[0]) < 1e-10
|
||||
&& std::abs(value[1] - rhs.value[1]) < 1e-10
|
||||
&& std::abs(value[2] - rhs.value[2]) < 1e-10
|
||||
&& std::abs(value[3] - rhs.value[3]) < 1e-10;
|
||||
return std::fabs(value[0] - rhs.value[0]) < 1e-10
|
||||
&& std::fabs(value[1] - rhs.value[1]) < 1e-10
|
||||
&& std::fabs(value[2] - rhs.value[2]) < 1e-10
|
||||
&& std::fabs(value[3] - rhs.value[3]) < 1e-10;
|
||||
} else {
|
||||
return std::abs(value[0] - rhs.value[0]) < 1e-10
|
||||
&& std::abs(value[1] - rhs.value[1]) < 1e-10;
|
||||
return std::fabs(value[0] - rhs.value[0]) < 1e-10
|
||||
&& std::fabs(value[1] - rhs.value[1]) < 1e-10;
|
||||
}
|
||||
}
|
||||
|
||||
template<typename U = T, typename = typename std::enable_if<std::is_integral<U>::value>::type>
|
||||
bool operator ==(const Threshold<T> &rhs) const
|
||||
template<typename U = T>
|
||||
typename std::enable_if<std::is_integral<U>::value, bool>::type operator ==(const Threshold<U> &rhs) const
|
||||
{
|
||||
if (_isDouble) {
|
||||
return
|
||||
|
Reference in New Issue
Block a user