1
0
Fork 0
mirror of https://github.com/bolero-MURAKAMI/Sprout synced 2025-08-03 12:49:50 +00:00

add SPROUT_ASSERT

This commit is contained in:
bolero-MURAKAMI 2013-03-18 19:12:21 +09:00
parent a5e14e71e1
commit 07f052fb6e
32 changed files with 386 additions and 284 deletions

View file

@ -2,12 +2,12 @@
#define SPROUT_MATH_FACTORIAL_HPP
#include <cstddef>
#include <stdexcept>
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/array/array.hpp>
#include <sprout/type_traits/is_int.hpp>
#include <sprout/type_traits/is_uint.hpp>
#include <sprout/assert.hpp>
namespace sprout {
namespace math {
@ -767,9 +767,8 @@ namespace sprout {
template<typename T, typename = typename std::enable_if<std::is_arithmetic<T>::value>::type>
inline SPROUT_CONSTEXPR T factorial(std::size_t x) {
typedef typename std::remove_cv<T>::type type;
return x <= sprout::math::factorial_limit<type>()
? sprout::math::detail::factorials<type>::table[x]
: throw std::invalid_argument("factorial(): argument limit exceeded")
return SPROUT_ASSERT(x <= sprout::math::factorial_limit<type>()),
sprout::math::detail::factorials<type>::table[x]
;
}
} // namespace math