add sprout/rational.hpp

add sprout/math/common_factor.hpp
This commit is contained in:
bolero-MURAKAMI 2012-05-25 22:21:16 +09:00
parent dc8cb3d14e
commit 5a9b2e4f7d
8 changed files with 1153 additions and 119 deletions

View file

@ -1,7 +1,9 @@
#ifndef SPROUT_CSTDLIB_ABS_HPP
#define SPROUT_CSTDLIB_ABS_HPP
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/utility/enabler_if.hpp>
namespace sprout {
// Copyright (C) 2011 RiSK (sscrisk)
@ -26,6 +28,25 @@ namespace sprout {
SPROUT_CONSTEXPR long long abs(long long j) {
return sprout::llabs(j);
}
template<
typename IntType,
typename sprout::enabler_if<
std::is_integral<IntType>::value && std::is_signed<IntType>::value
>::type = sprout::enabler
>
SPROUT_CONSTEXPR IntType abs(IntType j) {
return j < 0 ? -j : j;
}
template<
typename IntType,
typename sprout::enabler_if<
std::is_integral<IntType>::value && std::is_unsigned<IntType>::value
>::type = sprout::enabler
>
SPROUT_CONSTEXPR IntType abs(IntType j) {
return j;
}
} // namespace sprout
#endif // #ifndef SPROUT_CSTDLIB_ABS_HPP