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

add compost utility

This commit is contained in:
bolero-MURAKAMI 2012-12-07 02:31:16 +09:00
parent 24d2a229f3
commit b44f7c8f2a
14 changed files with 670 additions and 29 deletions

28
sprout/detail/pow.hpp Normal file
View file

@ -0,0 +1,28 @@
#ifndef SPROUT_DETAIL_POW_HPP
#define SPROUT_DETAIL_POW_HPP
#include <sprout/config.hpp>
namespace sprout {
namespace detail {
template<typename T>
inline SPROUT_CONSTEXPR T
pow2(T const& x) {
return x * x;
}
template<typename T>
inline SPROUT_CONSTEXPR T
pow3(T const& x) {
return x * x * x;
}
template<typename T>
inline SPROUT_CONSTEXPR T
pow_n(T const& x, int n) {
return n == 1 ? x
: n % 2 ? x * sprout::detail::pow2(sprout::detail::pow_n(x, n / 2))
: sprout::detail::pow2(sprout::detail::pow_n(x, n / 2))
;
}
} // namespace detail
} // namespace sprout
#endif // #ifndef SPROUT_DETAIL_POW_HPP