From 9a229b824f2bb9cbe3d44ffdf05f6167577aad7e Mon Sep 17 00:00:00 2001 From: bolero-MURAKAMI Date: Sun, 30 Oct 2011 14:48:10 +0900 Subject: [PATCH] =?UTF-8?q?make=5Farray=20=E4=BB=95=E6=A7=98=E5=A4=89?= =?UTF-8?q?=E6=9B=B4=20make=5Fcommon=5Farray=20=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sprout/array.hpp | 17 +++++++++++------ sprout/math/factorial.hpp | 9 ++++++++- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/sprout/array.hpp b/sprout/array.hpp index 87d498b2..d1c29fc4 100644 --- a/sprout/array.hpp +++ b/sprout/array.hpp @@ -11,6 +11,7 @@ #include #include #include +#include #include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT_DETAIL #if SPROUT_USE_INDEX_ITERATOR_IMPLEMENTATION # include @@ -245,13 +246,17 @@ namespace sprout { // // make_array // - template - SPROUT_CONSTEXPR inline sprout::array make_array(T const& head, Tail const&... tail) { - return sprout::array{{head, tail...}}; + template + SPROUT_CONSTEXPR inline sprout::array make_array(Types&&... args) { + return sprout::array::type, sizeof...(Types)>{{sprout::forward(args)...}}; } - template - SPROUT_CONSTEXPR inline sprout::array make_array() { - return sprout::array{}; + + // + // make_common_array + // + template + SPROUT_CONSTEXPR inline sprout::array::type...>::type, sizeof...(Types)> make_common_array(Types&&... args) { + return sprout::array::type...>::type, sizeof...(Types)>{{sprout::forward(args)...}}; } namespace detail { diff --git a/sprout/math/factorial.hpp b/sprout/math/factorial.hpp index f86aee9d..ed2239e0 100644 --- a/sprout/math/factorial.hpp +++ b/sprout/math/factorial.hpp @@ -629,11 +629,18 @@ namespace sprout { SPROUT_CONSTEXPR typename sprout::math::detail::factorials::table_type sprout::math::detail::factorials::table; } // namespace detail // + // factorial_limit + // + template + SPROUT_CONSTEXPR std::size_t factorial_limit() { + return sprout::math::detail::factorials::limit; + } + // // factorial // template SPROUT_CONSTEXPR T factorial(std::size_t x) { - return x <= sprout::math::detail::factorials::limit + return x <= sprout::math::factorial_limit() ? sprout::math::detail::factorials::table[x] : throw std::invalid_argument("factorial(): argument limit exceeded") ;