Make <cmath> classification macros work with integral types.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@172461 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
1b031c947f
commit
b05a55675f
@ -137,21 +137,21 @@ long double tanhl(long double x);
|
||||
|
||||
// C99
|
||||
|
||||
bool signbit(floating_point x);
|
||||
bool signbit(arithmetic x);
|
||||
|
||||
int fpclassify(floating_point x);
|
||||
int fpclassify(arithmetic x);
|
||||
|
||||
bool isfinite(floating_point x);
|
||||
bool isinf(floating_point x);
|
||||
bool isnan(floating_point x);
|
||||
bool isnormal(floating_point x);
|
||||
bool isfinite(arithmetic x);
|
||||
bool isinf(arithmetic x);
|
||||
bool isnan(arithmetic x);
|
||||
bool isnormal(arithmetic x);
|
||||
|
||||
bool isgreater(floating_point x, floating_point y);
|
||||
bool isgreaterequal(floating_point x, floating_point y);
|
||||
bool isless(floating_point x, floating_point y);
|
||||
bool islessequal(floating_point x, floating_point y);
|
||||
bool islessgreater(floating_point x, floating_point y);
|
||||
bool isunordered(floating_point x, floating_point y);
|
||||
bool isgreater(arithmetic x, arithmetic y);
|
||||
bool isgreaterequal(arithmetic x, arithmetic y);
|
||||
bool isless(arithmetic x, arithmetic y);
|
||||
bool islessequal(arithmetic x, arithmetic y);
|
||||
bool islessgreater(arithmetic x, arithmetic y);
|
||||
bool isunordered(arithmetic x, arithmetic y);
|
||||
|
||||
floating_point acosh (arithmetic x);
|
||||
float acoshf(float x);
|
||||
@ -325,10 +325,10 @@ __libcpp_signbit(_A1 __x) _NOEXCEPT
|
||||
|
||||
template <class _A1>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type
|
||||
typename std::enable_if<std::is_arithmetic<_A1>::value, bool>::type
|
||||
signbit(_A1 __x) _NOEXCEPT
|
||||
{
|
||||
return __libcpp_signbit(__x);
|
||||
return __libcpp_signbit((typename std::__promote<_A1>::type)__x);
|
||||
}
|
||||
|
||||
#endif // signbit
|
||||
@ -349,10 +349,10 @@ __libcpp_fpclassify(_A1 __x) _NOEXCEPT
|
||||
|
||||
template <class _A1>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
typename std::enable_if<std::is_floating_point<_A1>::value, int>::type
|
||||
typename std::enable_if<std::is_arithmetic<_A1>::value, int>::type
|
||||
fpclassify(_A1 __x) _NOEXCEPT
|
||||
{
|
||||
return __libcpp_fpclassify(__x);
|
||||
return __libcpp_fpclassify((typename std::__promote<_A1>::type)__x);
|
||||
}
|
||||
|
||||
#endif // fpclassify
|
||||
@ -373,10 +373,10 @@ __libcpp_isfinite(_A1 __x) _NOEXCEPT
|
||||
|
||||
template <class _A1>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type
|
||||
typename std::enable_if<std::is_arithmetic<_A1>::value, bool>::type
|
||||
isfinite(_A1 __x) _NOEXCEPT
|
||||
{
|
||||
return __libcpp_isfinite(__x);
|
||||
return __libcpp_isfinite((typename std::__promote<_A1>::type)__x);
|
||||
}
|
||||
|
||||
#endif // isfinite
|
||||
@ -397,10 +397,10 @@ __libcpp_isinf(_A1 __x) _NOEXCEPT
|
||||
|
||||
template <class _A1>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type
|
||||
typename std::enable_if<std::is_arithmetic<_A1>::value, bool>::type
|
||||
isinf(_A1 __x) _NOEXCEPT
|
||||
{
|
||||
return __libcpp_isinf(__x);
|
||||
return __libcpp_isinf((typename std::__promote<_A1>::type)__x);
|
||||
}
|
||||
|
||||
#endif // isinf
|
||||
@ -421,10 +421,10 @@ __libcpp_isnan(_A1 __x) _NOEXCEPT
|
||||
|
||||
template <class _A1>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type
|
||||
typename std::enable_if<std::is_arithmetic<_A1>::value, bool>::type
|
||||
isnan(_A1 __x) _NOEXCEPT
|
||||
{
|
||||
return __libcpp_isnan(__x);
|
||||
return __libcpp_isnan((typename std::__promote<_A1>::type)__x);
|
||||
}
|
||||
|
||||
#endif // isnan
|
||||
@ -445,10 +445,10 @@ __libcpp_isnormal(_A1 __x) _NOEXCEPT
|
||||
|
||||
template <class _A1>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type
|
||||
typename std::enable_if<std::is_arithmetic<_A1>::value, bool>::type
|
||||
isnormal(_A1 __x) _NOEXCEPT
|
||||
{
|
||||
return __libcpp_isnormal(__x);
|
||||
return __libcpp_isnormal((typename std::__promote<_A1>::type)__x);
|
||||
}
|
||||
|
||||
#endif // isnormal
|
||||
@ -471,13 +471,14 @@ template <class _A1, class _A2>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
typename std::enable_if
|
||||
<
|
||||
std::is_floating_point<_A1>::value &&
|
||||
std::is_floating_point<_A2>::value,
|
||||
std::is_arithmetic<_A1>::value &&
|
||||
std::is_arithmetic<_A2>::value,
|
||||
bool
|
||||
>::type
|
||||
isgreater(_A1 __x, _A2 __y) _NOEXCEPT
|
||||
{
|
||||
return __libcpp_isgreater(__x, __y);
|
||||
typedef typename std::__promote<_A1, _A2>::type type;
|
||||
return __libcpp_isgreater((type)__x, (type)__y);
|
||||
}
|
||||
|
||||
#endif // isgreater
|
||||
@ -500,13 +501,14 @@ template <class _A1, class _A2>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
typename std::enable_if
|
||||
<
|
||||
std::is_floating_point<_A1>::value &&
|
||||
std::is_floating_point<_A2>::value,
|
||||
std::is_arithmetic<_A1>::value &&
|
||||
std::is_arithmetic<_A2>::value,
|
||||
bool
|
||||
>::type
|
||||
isgreaterequal(_A1 __x, _A2 __y) _NOEXCEPT
|
||||
{
|
||||
return __libcpp_isgreaterequal(__x, __y);
|
||||
typedef typename std::__promote<_A1, _A2>::type type;
|
||||
return __libcpp_isgreaterequal((type)__x, (type)__y);
|
||||
}
|
||||
|
||||
#endif // isgreaterequal
|
||||
@ -529,13 +531,14 @@ template <class _A1, class _A2>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
typename std::enable_if
|
||||
<
|
||||
std::is_floating_point<_A1>::value &&
|
||||
std::is_floating_point<_A2>::value,
|
||||
std::is_arithmetic<_A1>::value &&
|
||||
std::is_arithmetic<_A2>::value,
|
||||
bool
|
||||
>::type
|
||||
isless(_A1 __x, _A2 __y) _NOEXCEPT
|
||||
{
|
||||
return __libcpp_isless(__x, __y);
|
||||
typedef typename std::__promote<_A1, _A2>::type type;
|
||||
return __libcpp_isless((type)__x, (type)__y);
|
||||
}
|
||||
|
||||
#endif // isless
|
||||
@ -558,13 +561,14 @@ template <class _A1, class _A2>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
typename std::enable_if
|
||||
<
|
||||
std::is_floating_point<_A1>::value &&
|
||||
std::is_floating_point<_A2>::value,
|
||||
std::is_arithmetic<_A1>::value &&
|
||||
std::is_arithmetic<_A2>::value,
|
||||
bool
|
||||
>::type
|
||||
islessequal(_A1 __x, _A2 __y) _NOEXCEPT
|
||||
{
|
||||
return __libcpp_islessequal(__x, __y);
|
||||
typedef typename std::__promote<_A1, _A2>::type type;
|
||||
return __libcpp_islessequal((type)__x, (type)__y);
|
||||
}
|
||||
|
||||
#endif // islessequal
|
||||
@ -587,13 +591,14 @@ template <class _A1, class _A2>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
typename std::enable_if
|
||||
<
|
||||
std::is_floating_point<_A1>::value &&
|
||||
std::is_floating_point<_A2>::value,
|
||||
std::is_arithmetic<_A1>::value &&
|
||||
std::is_arithmetic<_A2>::value,
|
||||
bool
|
||||
>::type
|
||||
islessgreater(_A1 __x, _A2 __y) _NOEXCEPT
|
||||
{
|
||||
return __libcpp_islessgreater(__x, __y);
|
||||
typedef typename std::__promote<_A1, _A2>::type type;
|
||||
return __libcpp_islessgreater((type)__x, (type)__y);
|
||||
}
|
||||
|
||||
#endif // islessgreater
|
||||
@ -616,13 +621,14 @@ template <class _A1, class _A2>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
typename std::enable_if
|
||||
<
|
||||
std::is_floating_point<_A1>::value &&
|
||||
std::is_floating_point<_A2>::value,
|
||||
std::is_arithmetic<_A1>::value &&
|
||||
std::is_arithmetic<_A2>::value,
|
||||
bool
|
||||
>::type
|
||||
isunordered(_A1 __x, _A2 __y) _NOEXCEPT
|
||||
{
|
||||
return __libcpp_isunordered(__x, __y);
|
||||
typedef typename std::__promote<_A1, _A2>::type type;
|
||||
return __libcpp_isunordered((type)__x, (type)__y);
|
||||
}
|
||||
|
||||
#endif // isunordered
|
||||
|
@ -433,6 +433,7 @@ void test_signbit()
|
||||
#endif
|
||||
static_assert((std::is_same<decltype(std::signbit((float)0)), bool>::value), "");
|
||||
static_assert((std::is_same<decltype(std::signbit((double)0)), bool>::value), "");
|
||||
static_assert((std::is_same<decltype(std::signbit(0)), bool>::value), "");
|
||||
static_assert((std::is_same<decltype(std::signbit((long double)0)), bool>::value), "");
|
||||
assert(std::signbit(-1.0) == true);
|
||||
}
|
||||
@ -444,6 +445,7 @@ void test_fpclassify()
|
||||
#endif
|
||||
static_assert((std::is_same<decltype(std::fpclassify((float)0)), int>::value), "");
|
||||
static_assert((std::is_same<decltype(std::fpclassify((double)0)), int>::value), "");
|
||||
static_assert((std::is_same<decltype(std::fpclassify(0)), int>::value), "");
|
||||
static_assert((std::is_same<decltype(std::fpclassify((long double)0)), int>::value), "");
|
||||
assert(std::fpclassify(-1.0) == FP_NORMAL);
|
||||
}
|
||||
@ -455,6 +457,7 @@ void test_isfinite()
|
||||
#endif
|
||||
static_assert((std::is_same<decltype(std::isfinite((float)0)), bool>::value), "");
|
||||
static_assert((std::is_same<decltype(std::isfinite((double)0)), bool>::value), "");
|
||||
static_assert((std::is_same<decltype(std::isfinite(0)), bool>::value), "");
|
||||
static_assert((std::is_same<decltype(std::isfinite((long double)0)), bool>::value), "");
|
||||
assert(std::isfinite(-1.0) == true);
|
||||
}
|
||||
@ -466,6 +469,7 @@ void test_isinf()
|
||||
#endif
|
||||
static_assert((std::is_same<decltype(std::isinf((float)0)), bool>::value), "");
|
||||
static_assert((std::is_same<decltype(std::isinf((double)0)), bool>::value), "");
|
||||
static_assert((std::is_same<decltype(std::isinf(0)), bool>::value), "");
|
||||
static_assert((std::is_same<decltype(std::isinf((long double)0)), bool>::value), "");
|
||||
assert(std::isinf(-1.0) == false);
|
||||
}
|
||||
@ -477,6 +481,7 @@ void test_isnan()
|
||||
#endif
|
||||
static_assert((std::is_same<decltype(std::isnan((float)0)), bool>::value), "");
|
||||
static_assert((std::is_same<decltype(std::isnan((double)0)), bool>::value), "");
|
||||
static_assert((std::is_same<decltype(std::isnan(0)), bool>::value), "");
|
||||
static_assert((std::is_same<decltype(std::isnan((long double)0)), bool>::value), "");
|
||||
assert(std::isnan(-1.0) == false);
|
||||
}
|
||||
@ -488,6 +493,7 @@ void test_isnormal()
|
||||
#endif
|
||||
static_assert((std::is_same<decltype(std::isnormal((float)0)), bool>::value), "");
|
||||
static_assert((std::is_same<decltype(std::isnormal((double)0)), bool>::value), "");
|
||||
static_assert((std::is_same<decltype(std::isnormal(0)), bool>::value), "");
|
||||
static_assert((std::is_same<decltype(std::isnormal((long double)0)), bool>::value), "");
|
||||
assert(std::isnormal(-1.0) == true);
|
||||
}
|
||||
@ -502,6 +508,7 @@ void test_isgreater()
|
||||
static_assert((std::is_same<decltype(std::isgreater((float)0, (long double)0)), bool>::value), "");
|
||||
static_assert((std::is_same<decltype(std::isgreater((double)0, (float)0)), bool>::value), "");
|
||||
static_assert((std::is_same<decltype(std::isgreater((double)0, (double)0)), bool>::value), "");
|
||||
static_assert((std::is_same<decltype(std::isgreater(0, (double)0)), bool>::value), "");
|
||||
static_assert((std::is_same<decltype(std::isgreater((double)0, (long double)0)), bool>::value), "");
|
||||
static_assert((std::is_same<decltype(std::isgreater((long double)0, (float)0)), bool>::value), "");
|
||||
static_assert((std::is_same<decltype(std::isgreater((long double)0, (double)0)), bool>::value), "");
|
||||
@ -519,6 +526,7 @@ void test_isgreaterequal()
|
||||
static_assert((std::is_same<decltype(std::isgreaterequal((float)0, (long double)0)), bool>::value), "");
|
||||
static_assert((std::is_same<decltype(std::isgreaterequal((double)0, (float)0)), bool>::value), "");
|
||||
static_assert((std::is_same<decltype(std::isgreaterequal((double)0, (double)0)), bool>::value), "");
|
||||
static_assert((std::is_same<decltype(std::isgreaterequal(0, (double)0)), bool>::value), "");
|
||||
static_assert((std::is_same<decltype(std::isgreaterequal((double)0, (long double)0)), bool>::value), "");
|
||||
static_assert((std::is_same<decltype(std::isgreaterequal((long double)0, (float)0)), bool>::value), "");
|
||||
static_assert((std::is_same<decltype(std::isgreaterequal((long double)0, (double)0)), bool>::value), "");
|
||||
@ -536,6 +544,7 @@ void test_isless()
|
||||
static_assert((std::is_same<decltype(std::isless((float)0, (long double)0)), bool>::value), "");
|
||||
static_assert((std::is_same<decltype(std::isless((double)0, (float)0)), bool>::value), "");
|
||||
static_assert((std::is_same<decltype(std::isless((double)0, (double)0)), bool>::value), "");
|
||||
static_assert((std::is_same<decltype(std::isless(0, (double)0)), bool>::value), "");
|
||||
static_assert((std::is_same<decltype(std::isless((double)0, (long double)0)), bool>::value), "");
|
||||
static_assert((std::is_same<decltype(std::isless((long double)0, (float)0)), bool>::value), "");
|
||||
static_assert((std::is_same<decltype(std::isless((long double)0, (double)0)), bool>::value), "");
|
||||
@ -553,6 +562,7 @@ void test_islessequal()
|
||||
static_assert((std::is_same<decltype(std::islessequal((float)0, (long double)0)), bool>::value), "");
|
||||
static_assert((std::is_same<decltype(std::islessequal((double)0, (float)0)), bool>::value), "");
|
||||
static_assert((std::is_same<decltype(std::islessequal((double)0, (double)0)), bool>::value), "");
|
||||
static_assert((std::is_same<decltype(std::islessequal(0, (double)0)), bool>::value), "");
|
||||
static_assert((std::is_same<decltype(std::islessequal((double)0, (long double)0)), bool>::value), "");
|
||||
static_assert((std::is_same<decltype(std::islessequal((long double)0, (float)0)), bool>::value), "");
|
||||
static_assert((std::is_same<decltype(std::islessequal((long double)0, (double)0)), bool>::value), "");
|
||||
@ -570,6 +580,7 @@ void test_islessgreater()
|
||||
static_assert((std::is_same<decltype(std::islessgreater((float)0, (long double)0)), bool>::value), "");
|
||||
static_assert((std::is_same<decltype(std::islessgreater((double)0, (float)0)), bool>::value), "");
|
||||
static_assert((std::is_same<decltype(std::islessgreater((double)0, (double)0)), bool>::value), "");
|
||||
static_assert((std::is_same<decltype(std::islessgreater(0, (double)0)), bool>::value), "");
|
||||
static_assert((std::is_same<decltype(std::islessgreater((double)0, (long double)0)), bool>::value), "");
|
||||
static_assert((std::is_same<decltype(std::islessgreater((long double)0, (float)0)), bool>::value), "");
|
||||
static_assert((std::is_same<decltype(std::islessgreater((long double)0, (double)0)), bool>::value), "");
|
||||
@ -587,6 +598,7 @@ void test_isunordered()
|
||||
static_assert((std::is_same<decltype(std::isunordered((float)0, (long double)0)), bool>::value), "");
|
||||
static_assert((std::is_same<decltype(std::isunordered((double)0, (float)0)), bool>::value), "");
|
||||
static_assert((std::is_same<decltype(std::isunordered((double)0, (double)0)), bool>::value), "");
|
||||
static_assert((std::is_same<decltype(std::isunordered(0, (double)0)), bool>::value), "");
|
||||
static_assert((std::is_same<decltype(std::isunordered((double)0, (long double)0)), bool>::value), "");
|
||||
static_assert((std::is_same<decltype(std::isunordered((long double)0, (float)0)), bool>::value), "");
|
||||
static_assert((std::is_same<decltype(std::isunordered((long double)0, (double)0)), bool>::value), "");
|
||||
|
Loading…
Reference in New Issue
Block a user