mirror of
https://github.com/bolero-MURAKAMI/Sprout.git
synced 2025-07-16 15:14:13 +00:00
fix coding-stype
This commit is contained in:
parent
2012838899
commit
df3023db30
196 changed files with 2510 additions and 3945 deletions
|
@ -17,11 +17,11 @@ namespace sprout {
|
|||
// Copyright (c) 2011 osyo-manga : http://d.hatena.ne.jp/osyo-manga/
|
||||
|
||||
template<typename IntType, typename CStrIterator>
|
||||
inline SPROUT_CONSTEXPR IntType str_to_int_impl_1(CStrIterator str, int base, IntType val, IntType x, bool negative) {
|
||||
return x == static_cast<IntType>(-1)
|
||||
? (negative ? -val : val)
|
||||
inline SPROUT_CONSTEXPR IntType
|
||||
str_to_int_impl_1(CStrIterator str, int base, IntType val, IntType x, bool negative) {
|
||||
return x == static_cast<IntType>(-1) ? (negative ? -val : val)
|
||||
: val > (std::numeric_limits<IntType>::max() - x - (negative ? 1 : 0)) / base
|
||||
? (negative ? std::numeric_limits<IntType>::min() : std::numeric_limits<IntType>::max())
|
||||
? (negative ? std::numeric_limits<IntType>::min() : std::numeric_limits<IntType>::max())
|
||||
: sprout::detail::str_to_int_impl_1<IntType>(
|
||||
sprout::next(str),
|
||||
base,
|
||||
|
@ -32,7 +32,8 @@ namespace sprout {
|
|||
;
|
||||
}
|
||||
template<typename IntType, typename CStrIterator>
|
||||
inline SPROUT_CONSTEXPR IntType str_to_int_impl(CStrIterator str, int base, bool negative) {
|
||||
inline SPROUT_CONSTEXPR IntType
|
||||
str_to_int_impl(CStrIterator str, int base, bool negative) {
|
||||
return *str == static_cast<typename std::iterator_traits<CStrIterator>::value_type>('0')
|
||||
? *sprout::next(str) == static_cast<typename std::iterator_traits<CStrIterator>::value_type>('x')
|
||||
|| *sprout::next(str) == static_cast<typename std::iterator_traits<CStrIterator>::value_type>('X')
|
||||
|
@ -60,27 +61,30 @@ namespace sprout {
|
|||
;
|
||||
}
|
||||
template<typename IntType, typename CStrIterator, typename sprout::enabler_if<std::is_unsigned<IntType>::value>::type = sprout::enabler>
|
||||
inline SPROUT_CONSTEXPR IntType str_to_int(CStrIterator str, int base) {
|
||||
inline SPROUT_CONSTEXPR IntType
|
||||
str_to_int(CStrIterator str, int base) {
|
||||
return sprout::ascii::isspace(*str)
|
||||
? sprout::detail::str_to_int<IntType>(sprout::next(str), base)
|
||||
? sprout::detail::str_to_int<IntType>(sprout::next(str), base)
|
||||
: *str == static_cast<typename std::iterator_traits<CStrIterator>::value_type>('+')
|
||||
? sprout::detail::str_to_int_impl<IntType>(sprout::next(str), base, false)
|
||||
? sprout::detail::str_to_int_impl<IntType>(sprout::next(str), base, false)
|
||||
: sprout::detail::str_to_int_impl<IntType>(str, base, false)
|
||||
;
|
||||
}
|
||||
template<typename IntType, typename CStrIterator, typename sprout::enabler_if<std::is_signed<IntType>::value>::type = sprout::enabler>
|
||||
inline SPROUT_CONSTEXPR IntType str_to_int(CStrIterator str, int base) {
|
||||
inline SPROUT_CONSTEXPR IntType
|
||||
str_to_int(CStrIterator str, int base) {
|
||||
return sprout::ascii::isspace(*str)
|
||||
? sprout::detail::str_to_int<IntType>(sprout::next(str), base)
|
||||
? sprout::detail::str_to_int<IntType>(sprout::next(str), base)
|
||||
: *str == static_cast<typename std::iterator_traits<CStrIterator>::value_type>('-')
|
||||
? sprout::detail::str_to_int_impl<IntType>(sprout::next(str), base, true)
|
||||
? sprout::detail::str_to_int_impl<IntType>(sprout::next(str), base, true)
|
||||
: *str == static_cast<typename std::iterator_traits<CStrIterator>::value_type>('+')
|
||||
? sprout::detail::str_to_int_impl<IntType>(sprout::next(str), base, false)
|
||||
? sprout::detail::str_to_int_impl<IntType>(sprout::next(str), base, false)
|
||||
: sprout::detail::str_to_int_impl<IntType>(str, base, false)
|
||||
;
|
||||
}
|
||||
template<typename IntType, typename CStrIterator, typename CharPtr>
|
||||
inline SPROUT_CONSTEXPR IntType str_to_int(CStrIterator str, CharPtr* endptr, int base) {
|
||||
inline SPROUT_CONSTEXPR IntType
|
||||
str_to_int(CStrIterator str, CharPtr* endptr, int base) {
|
||||
return !endptr ? sprout::detail::str_to_int<IntType>(str, base)
|
||||
: std::is_signed<IntType>::value
|
||||
? sizeof(IntType) <= sizeof(long) ? static_cast<IntType>(std::strtol(&*str, endptr, base))
|
||||
|
@ -97,15 +101,18 @@ namespace sprout {
|
|||
// str_to_int
|
||||
//
|
||||
template<typename IntType, typename Char, typename sprout::enabler_if<std::is_integral<IntType>::value>::type = sprout::enabler>
|
||||
inline SPROUT_CONSTEXPR IntType str_to_int(Char const* str, Char** endptr, int base = 10) {
|
||||
inline SPROUT_CONSTEXPR IntType
|
||||
str_to_int(Char const* str, Char** endptr, int base = 10) {
|
||||
return sprout::detail::str_to_int<IntType>(str, endptr, base);
|
||||
}
|
||||
template<typename IntType, typename Char, typename sprout::enabler_if<std::is_integral<IntType>::value>::type = sprout::enabler>
|
||||
inline SPROUT_CONSTEXPR IntType str_to_int(Char const* str, std::nullptr_t endptr, int base = 10) {
|
||||
inline SPROUT_CONSTEXPR IntType
|
||||
str_to_int(Char const* str, std::nullptr_t endptr, int base = 10) {
|
||||
return sprout::detail::str_to_int<IntType>(str, base);
|
||||
}
|
||||
template<typename IntType, typename Char, typename sprout::enabler_if<std::is_integral<IntType>::value>::type = sprout::enabler>
|
||||
inline SPROUT_CONSTEXPR IntType str_to_int(Char const* str, int base = 10) {
|
||||
inline SPROUT_CONSTEXPR IntType
|
||||
str_to_int(Char const* str, int base = 10) {
|
||||
return sprout::detail::str_to_int<IntType>(str, base);
|
||||
}
|
||||
} // namespace sprout
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue