#ifndef SPROUT_MATH_CBRT_HPP #define SPROUT_MATH_CBRT_HPP #include #include #include #include #include #include #include namespace sprout { namespace math { namespace detail { template< typename FloatType, typename sprout::enabler_if::value>::type = sprout::enabler > inline SPROUT_CONSTEXPR FloatType cbrt(FloatType x) { return x == 0 ? FloatType(0) : x == std::numeric_limits::infinity() ? std::numeric_limits::infinity() : x == -std::numeric_limits::infinity() ? -std::numeric_limits::infinity() : x < 0 ? -sprout::math::pow(-x, sprout::math::third()) : sprout::math::pow(x, sprout::math::third()) ; } template< typename IntType, typename sprout::enabler_if::value>::type = sprout::enabler > inline SPROUT_CONSTEXPR double cbrt(IntType x) { return sprout::math::detail::cbrt(static_cast(x)); } } // namespace detail using NS_SPROUT_MATH_DETAIL::cbrt; } // namespace math using sprout::math::cbrt; } // namespace sprout #endif // #ifndef SPROUT_MATH_CBRT_HPP