diff --git a/sprout/math/factorial.hpp b/sprout/math/factorial.hpp index 647be965..213ba5d3 100644 --- a/sprout/math/factorial.hpp +++ b/sprout/math/factorial.hpp @@ -17,7 +17,10 @@ namespace sprout { typedef std::int8_t type; public: SPROUT_STATIC_CONSTEXPR std::size_t limit = 5; - SPROUT_STATIC_CONSTEXPR sprout::array table{{ + public: + typedef sprout::array table_type; + public: + SPROUT_STATIC_CONSTEXPR table_type table = table_type{{ 1, 1, 2, @@ -26,12 +29,16 @@ namespace sprout { 120 }}; }; + template<> struct factorials { public: typedef std::uint8_t type; public: SPROUT_STATIC_CONSTEXPR std::size_t limit = 5; - SPROUT_STATIC_CONSTEXPR sprout::array table{{ + public: + typedef sprout::array table_type; + public: + SPROUT_STATIC_CONSTEXPR table_type table = table_type{{ 1, 1, 2, @@ -46,7 +53,10 @@ namespace sprout { typedef std::int16_t type; public: SPROUT_STATIC_CONSTEXPR std::size_t limit = 7; - SPROUT_STATIC_CONSTEXPR sprout::array table{{ + public: + typedef sprout::array table_type; + public: + SPROUT_STATIC_CONSTEXPR table_type table = table_type{{ 1, 1, 2, @@ -63,7 +73,10 @@ namespace sprout { typedef std::uint16_t type; public: SPROUT_STATIC_CONSTEXPR std::size_t limit = 8; - SPROUT_STATIC_CONSTEXPR sprout::array table{{ + public: + typedef sprout::array table_type; + public: + SPROUT_STATIC_CONSTEXPR table_type table = table_type{{ 1, 1, 2, @@ -81,7 +94,10 @@ namespace sprout { typedef std::int32_t type; public: SPROUT_STATIC_CONSTEXPR std::size_t limit = 11; - SPROUT_STATIC_CONSTEXPR sprout::array table{{ + public: + typedef sprout::array table_type; + public: + SPROUT_STATIC_CONSTEXPR table_type table = table_type{{ 1, 1, 2, @@ -102,7 +118,10 @@ namespace sprout { typedef std::uint32_t type; public: SPROUT_STATIC_CONSTEXPR std::size_t limit = 11; - SPROUT_STATIC_CONSTEXPR sprout::array table{{ + public: + typedef sprout::array table_type; + public: + SPROUT_STATIC_CONSTEXPR table_type table = table_type{{ 1, 1, 2, @@ -120,10 +139,13 @@ namespace sprout { template<> struct factorials { public: - typedef std::int32_t type; + typedef std::int64_t type; public: SPROUT_STATIC_CONSTEXPR std::size_t limit = 20; - SPROUT_STATIC_CONSTEXPR sprout::array table{{ + public: + typedef sprout::array table_type; + public: + SPROUT_STATIC_CONSTEXPR table_type table = table_type{{ INT64_C(1), INT64_C(1), INT64_C(2), @@ -150,10 +172,13 @@ namespace sprout { template<> struct factorials { public: - typedef std::uint32_t type; + typedef std::uint64_t type; public: SPROUT_STATIC_CONSTEXPR std::size_t limit = 20; - SPROUT_STATIC_CONSTEXPR sprout::array table{{ + public: + typedef sprout::array table_type; + public: + SPROUT_STATIC_CONSTEXPR table_type table = table_type{{ UINT64_C(1), UINT64_C(1), UINT64_C(2), @@ -183,7 +208,10 @@ namespace sprout { typedef float type; public: SPROUT_STATIC_CONSTEXPR std::size_t limit = 34; - SPROUT_STATIC_CONSTEXPR sprout::array table{{ + public: + typedef sprout::array table_type; + public: + SPROUT_STATIC_CONSTEXPR table_type table = table_type{{ 1.0F, 1.0F, 2.0F, @@ -227,7 +255,10 @@ namespace sprout { typedef double type; public: SPROUT_STATIC_CONSTEXPR std::size_t limit = 170; - SPROUT_STATIC_CONSTEXPR sprout::array table{{ + public: + typedef sprout::array table_type; + public: + SPROUT_STATIC_CONSTEXPR table_type table = table_type{{ 1.0, 1.0, 2.0, @@ -407,7 +438,10 @@ namespace sprout { typedef long double type; public: SPROUT_STATIC_CONSTEXPR std::size_t limit = 170; - SPROUT_STATIC_CONSTEXPR sprout::array table{{ + public: + typedef sprout::array table_type; + public: + SPROUT_STATIC_CONSTEXPR table_type table = table_type{{ 1.0L, 1.0L, 2.0L, @@ -585,9 +619,9 @@ namespace sprout { template SPROUT_CONSTEXPR T factorial(std::size_t x) { - return x <= sprout::detail::factorials::limit - ? sprout::detail::factorials::table[x] - : throw "assert(x <= sprout::detail::factorials::limit)" + return x <= sprout::math::detail::factorials::limit + ? sprout::math::detail::factorials::table[x] + : throw "assert(x <= sprout::math::detail::factorials::limit)" ; } } // namespace math @@ -596,3 +630,4 @@ namespace sprout { } // namespace sprout #endif // #ifndef SPROUT_MATH_FACTORIAL_HPP +