mirror of
https://github.com/bolero-MURAKAMI/Sprout.git
synced 2025-07-12 14:54:10 +00:00
add type_traits/aliases.hpp
This commit is contained in:
parent
dacba801a6
commit
eaea3771fc
8 changed files with 153 additions and 36 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue