mirror of
https://github.com/bolero-MURAKAMI/Sprout.git
synced 2025-08-27 14:40:51 +00:00
fix: math functions (support for inferior C++14 standard)
add C++14 constexpr modifying algorithms
This commit is contained in:
parent
58cff54e0d
commit
c58c9cc0fc
106 changed files with 3465 additions and 2144 deletions
|
@ -17,16 +17,17 @@
|
|||
namespace sprout {
|
||||
namespace math {
|
||||
namespace detail {
|
||||
template<
|
||||
typename FloatType,
|
||||
typename sprout::enabler_if<std::is_floating_point<FloatType>::value>::type = sprout::enabler
|
||||
>
|
||||
#if SPROUT_USE_BUILTIN_CMATH_FUNCTION
|
||||
template<typename FloatType>
|
||||
inline SPROUT_CONSTEXPR bool
|
||||
signbit(FloatType x) {
|
||||
return !sprout::math::isnan(x) && x < 0;
|
||||
builtin_signbit(FloatType x) {
|
||||
return __builtin_signbit(x);
|
||||
}
|
||||
#endif
|
||||
} // namespace detail
|
||||
//
|
||||
// signbit
|
||||
//
|
||||
// issue:
|
||||
// [ !SPROUT_USE_BUILTIN_CMATH_FUNCTION ]
|
||||
// signbit(-0) returns false .
|
||||
|
@ -34,7 +35,28 @@ namespace sprout {
|
|||
// signbit(-NaN) returns false .
|
||||
// # returns true . ( same as signbit(+NaN) )
|
||||
//
|
||||
using NS_SPROUT_MATH_DETAIL::signbit;
|
||||
template<
|
||||
typename FloatType,
|
||||
typename sprout::enabler_if<std::is_floating_point<FloatType>::value>::type = sprout::enabler
|
||||
>
|
||||
inline SPROUT_CONSTEXPR bool
|
||||
signbit(FloatType x) {
|
||||
return
|
||||
#if SPROUT_USE_BUILTIN_CMATH_FUNCTION
|
||||
sprout::math::detail::builtin_signbit(x)
|
||||
#else
|
||||
!sprout::math::isnan(x) && x < 0
|
||||
#endif
|
||||
;
|
||||
}
|
||||
template<
|
||||
typename IntType,
|
||||
typename sprout::enabler_if<std::is_integral<IntType>::value>::type = sprout::enabler
|
||||
>
|
||||
inline SPROUT_CONSTEXPR bool
|
||||
signbit(IntType x) {
|
||||
return x < 0;
|
||||
}
|
||||
} // namespace math
|
||||
|
||||
using sprout::math::signbit;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue