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

fix to_string

fix from_string
fix filename typo
This commit is contained in:
bolero-MURAKAMI 2012-04-16 15:33:29 +09:00
parent c901c3058a
commit 09b4b56fad
6 changed files with 75 additions and 67 deletions

View file

@ -9,9 +9,9 @@
namespace sprout {
namespace detail {
template<typename Elem, typename IntType>
inline SPROUT_CONSTEXPR Elem int_to_char(IntType val, std::size_t base){
inline SPROUT_CONSTEXPR Elem int_to_char(IntType val, int base){
return val >= 0 && val < 10 ? static_cast<Elem>('0') + val
: val >= 10 && val < base ? static_cast<Elem>('a') + (val - 10)
: val >= 10 && val < static_cast<IntType>(base) ? static_cast<Elem>('a') + (val - 10)
: throw std::invalid_argument("value out of bounds")
;
}
@ -23,10 +23,10 @@ namespace sprout {
}
template<typename IntType, typename Elem>
inline SPROUT_CONSTEXPR IntType char_to_int(Elem c, std::size_t base){
return sprout::ascii::isdigit(c) && static_cast<std::size_t>(c - static_cast<Elem>('0')) < base ? c - static_cast<Elem>('0')
: sprout::ascii::islower(c) && static_cast<std::size_t>(c - static_cast<Elem>('a') + 10) < base ? c - static_cast<Elem>('a') + 10
: sprout::ascii::isupper(c) && static_cast<std::size_t>(c - static_cast<Elem>('A') + 10) < base ? c - static_cast<Elem>('A') + 10
inline SPROUT_CONSTEXPR IntType char_to_int(Elem c, int base){
return sprout::ascii::isdigit(c) && c - static_cast<Elem>('0') < base ? c - static_cast<Elem>('0')
: sprout::ascii::islower(c) && c - static_cast<Elem>('a') + 10 < base ? c - static_cast<Elem>('a') + 10
: sprout::ascii::isupper(c) && c - static_cast<Elem>('A') + 10 < base ? c - static_cast<Elem>('A') + 10
: static_cast<IntType>(-1)
;
}