add type_traits/aliases.hpp

This commit is contained in:
bolero-MURAKAMI 2012-05-26 19:19:08 +09:00
parent dacba801a6
commit eaea3771fc
8 changed files with 153 additions and 36 deletions

View file

@ -29,24 +29,26 @@ namespace sprout {
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 {
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;
}
} // anonymous-namespace
} // namespace sprout
#endif // #ifndef SPROUT_CSTDLIB_ABS_HPP