mirror of
https://github.com/bolero-MURAKAMI/Sprout
synced 2025-08-03 12:49:50 +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
|
@ -25,49 +25,45 @@
|
|||
|
||||
namespace sprout {
|
||||
namespace math {
|
||||
namespace detail {
|
||||
#if SPROUT_FLT_RADIX_IS_2
|
||||
template<
|
||||
typename FloatType,
|
||||
typename sprout::enabler_if<std::is_floating_point<FloatType>::value>::type = sprout::enabler
|
||||
>
|
||||
inline SPROUT_CONSTEXPR int
|
||||
ilogb2(FloatType x) {
|
||||
return sprout::math::ilogb(x);
|
||||
}
|
||||
template<
|
||||
typename IntType,
|
||||
typename sprout::enabler_if<std::is_integral<IntType>::value>::type = sprout::enabler
|
||||
>
|
||||
inline SPROUT_CONSTEXPR int
|
||||
ilogb2(IntType x) {
|
||||
return sprout::math::ilogb(x);
|
||||
}
|
||||
template<
|
||||
typename FloatType,
|
||||
typename sprout::enabler_if<std::is_floating_point<FloatType>::value>::type = sprout::enabler
|
||||
>
|
||||
inline SPROUT_CONSTEXPR int
|
||||
ilogb2(FloatType x) {
|
||||
return sprout::math::ilogb(x);
|
||||
}
|
||||
template<
|
||||
typename IntType,
|
||||
typename sprout::enabler_if<std::is_integral<IntType>::value>::type = sprout::enabler
|
||||
>
|
||||
inline SPROUT_CONSTEXPR int
|
||||
ilogb2(IntType x) {
|
||||
return sprout::math::ilogb(x);
|
||||
}
|
||||
#else
|
||||
template<
|
||||
typename FloatType,
|
||||
typename sprout::enabler_if<std::is_floating_point<FloatType>::value>::type = sprout::enabler
|
||||
>
|
||||
inline SPROUT_CONSTEXPR int
|
||||
ilogb2(FloatType x) {
|
||||
return sprout::math::iszero(x) ? FP_ILOGB0
|
||||
: sprout::math::isinf(x) ? INT_MAX
|
||||
: sprout::math::isnan(x) ? FP_ILOGBNAN
|
||||
: static_cast<int>(sprout::math::logb2(x))
|
||||
;
|
||||
}
|
||||
template<
|
||||
typename IntType,
|
||||
typename sprout::enabler_if<std::is_integral<IntType>::value>::type = sprout::enabler
|
||||
>
|
||||
inline SPROUT_CONSTEXPR int
|
||||
ilogb2(IntType x) {
|
||||
return sprout::math::detail::ilogb2(static_cast<double>(x));
|
||||
}
|
||||
template<
|
||||
typename FloatType,
|
||||
typename sprout::enabler_if<std::is_floating_point<FloatType>::value>::type = sprout::enabler
|
||||
>
|
||||
inline SPROUT_CONSTEXPR int
|
||||
ilogb2(FloatType x) {
|
||||
return sprout::math::iszero(x) ? FP_ILOGB0
|
||||
: sprout::math::isinf(x) ? INT_MAX
|
||||
: sprout::math::isnan(x) ? FP_ILOGBNAN
|
||||
: static_cast<int>(sprout::math::logb2(x))
|
||||
;
|
||||
}
|
||||
template<
|
||||
typename IntType,
|
||||
typename sprout::enabler_if<std::is_integral<IntType>::value>::type = sprout::enabler
|
||||
>
|
||||
inline SPROUT_CONSTEXPR int
|
||||
ilogb2(IntType x) {
|
||||
return sprout::math::ilogb2(static_cast<double>(x));
|
||||
}
|
||||
#endif
|
||||
} // namespace detail
|
||||
|
||||
using sprout::math::detail::ilogb2;
|
||||
} // namespace math
|
||||
|
||||
using sprout::math::ilogb2;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue