maths: add is_nan for arbitrary types

This commit is contained in:
Danny Robson 2017-01-23 21:47:53 +11:00
parent 5bb55f5437
commit 6f4bc6d6b2

View File

@ -176,6 +176,30 @@ namespace util {
}
//-------------------------------------------------------------------------
template <typename T>
constexpr
typename std::enable_if_t<
std::is_floating_point<T>::value, bool
>
is_nan (T t)
{
return std::isnan (t);
}
//-------------------------------------------------------------------------
template <typename T>
constexpr
typename std::enable_if_t<
!std::is_floating_point<T>::value, bool
>
is_nan (const T&)
{
return false;
}
///////////////////////////////////////////////////////////////////////////
template <typename T>
T