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

add C++14 version is_signed, is_unsigned

This commit is contained in:
bolero-MURAKAMI 2015-03-31 20:05:32 +09:00
parent b51e338b68
commit ead65bf7fd
79 changed files with 310 additions and 114 deletions

View file

@ -1,6 +1,8 @@
/*=============================================================================
Copyright (c) 2011 RiSK (sscrisk)
https://github.com/sscrisk/CEL---ConstExpr-Library
Copyright (c) 2011-2015 Bolero MURAKAMI
Copyright (C) 2011 RiSK (sscrisk)
https://github.com/bolero-MURAKAMI/Sprout
Distributed under the Boost Software License, Version 1.0. (See accompanying
@ -11,6 +13,7 @@
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/type_traits/std_type_traits.hpp>
namespace sprout {
@ -43,7 +46,7 @@ namespace sprout {
namespace {
template<typename IntType>
inline SPROUT_CONSTEXPR typename std::enable_if<
std::is_integral<IntType>::value && std::is_signed<IntType>::value,
std::is_integral<IntType>::value && sprout::is_signed<IntType>::value,
IntType
>::type
abs(IntType j) {
@ -52,7 +55,7 @@ namespace sprout {
template<typename IntType>
inline SPROUT_CONSTEXPR typename std::enable_if<
std::is_integral<IntType>::value && std::is_unsigned<IntType>::value,
std::is_integral<IntType>::value && sprout::is_unsigned<IntType>::value,
IntType
>::type
abs(IntType j) {

View file

@ -12,6 +12,7 @@
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/limits.hpp>
#include <sprout/type_traits/std_type_traits.hpp>
#include <sprout/iterator/operation.hpp>
#include <sprout/ctype/ascii.hpp>
#include <sprout/detail/char_literal.hpp>
@ -39,7 +40,7 @@ namespace sprout {
}
template<typename IntType, typename NullTerminatedIterator>
inline SPROUT_CONSTEXPR typename std::enable_if<
std::is_unsigned<IntType>::value,
sprout::is_unsigned<IntType>::value,
IntType
>::type
ascii_to_int(NullTerminatedIterator str) {
@ -53,7 +54,7 @@ namespace sprout {
}
template<typename IntType, typename NullTerminatedIterator>
inline SPROUT_CONSTEXPR typename std::enable_if<
std::is_signed<IntType>::value,
sprout::is_signed<IntType>::value,
IntType
>::type
ascii_to_int(NullTerminatedIterator str) {

View file

@ -1,6 +1,8 @@
/*=============================================================================
Copyright (c) 2011 RiSK (sscrisk)
https://github.com/sscrisk/CEL---ConstExpr-Library
Copyright (c) 2011-2015 Bolero MURAKAMI
Copyright (C) 2011 RiSK (sscrisk)
https://github.com/bolero-MURAKAMI/Sprout
Distributed under the Boost Software License, Version 1.0. (See accompanying

View file

@ -13,6 +13,7 @@
#include <sprout/config.hpp>
#include <sprout/workaround/std/cstddef.hpp>
#include <sprout/limits.hpp>
#include <sprout/type_traits/std_type_traits.hpp>
#include <sprout/iterator/operation.hpp>
#include <sprout/ctype/ascii.hpp>
#include <sprout/detail/char_literal.hpp>
@ -72,7 +73,7 @@ namespace sprout {
}
template<typename IntType, typename NullTerminatedIterator>
inline SPROUT_CONSTEXPR typename std::enable_if<
std::is_unsigned<IntType>::value,
sprout::is_unsigned<IntType>::value,
IntType
>::type
str_to_int(NullTerminatedIterator str, int base) {
@ -86,7 +87,7 @@ namespace sprout {
}
template<typename IntType, typename NullTerminatedIterator>
inline SPROUT_CONSTEXPR typename std::enable_if<
std::is_signed<IntType>::value,
sprout::is_signed<IntType>::value,
IntType
>::type
str_to_int(NullTerminatedIterator str, int base) {
@ -105,11 +106,11 @@ namespace sprout {
str_to_int(NullTerminatedIterator str, CharPtr* endptr, int base) {
return !endptr ? sprout::detail::str_to_int<IntType>(str, base)
#if defined(_MSC_VER)
: std::is_signed<IntType>::value
: sprout::is_signed<IntType>::value
? static_cast<IntType>(std::strtol(&*str, endptr, base))
: static_cast<IntType>(std::strtoul(&*str, endptr, base))
#elif defined(__MINGW32__)
: std::is_signed<IntType>::value
: sprout::is_signed<IntType>::value
? sizeof(IntType) <= sizeof(long) ? static_cast<IntType>(std::strtol(&*str, endptr, base))
: sizeof(IntType) <= sizeof(long long) ? static_cast<IntType>(::strtoll(&*str, endptr, base))
: static_cast<IntType>(std::strtoimax(&*str, endptr, base))
@ -117,7 +118,7 @@ namespace sprout {
: sizeof(IntType) <= sizeof(unsigned long long) ? static_cast<IntType>(::strtoull(&*str, endptr, base))
: static_cast<IntType>(std::strtoumax(&*str, endptr, base))
#else
: std::is_signed<IntType>::value
: sprout::is_signed<IntType>::value
? sizeof(IntType) <= sizeof(long) ? static_cast<IntType>(std::strtol(&*str, endptr, base))
: sizeof(IntType) <= sizeof(long long) ? static_cast<IntType>(std::strtoll(&*str, endptr, base))
: static_cast<IntType>(std::strtoimax(&*str, endptr, base))