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

@ -39,21 +39,21 @@ namespace sprout {
sprout::next(str, 2), sprout::next(str, 2),
base ? base : 16, base ? base : 16,
IntType(), IntType(),
sprout::detail::char_to_int<IntType>(*sprout::next(str, 2), base), sprout::detail::char_to_int<IntType>(*sprout::next(str, 2), base ? base : 16),
negative negative
) )
: sprout::detail::str_to_int_impl_1<IntType>( : sprout::detail::str_to_int_impl_1<IntType>(
sprout::next(str), sprout::next(str),
base ? base : 8, base ? base : 8,
IntType(), IntType(),
sprout::detail::char_to_int<IntType>(*sprout::next(str), base), sprout::detail::char_to_int<IntType>(*sprout::next(str), base ? base : 8),
negative negative
) )
: sprout::detail::str_to_int_impl_1<IntType>( : sprout::detail::str_to_int_impl_1<IntType>(
str, str,
base ? base : 10, base ? base : 10,
IntType(), IntType(),
sprout::detail::char_to_int<IntType>(*str, base), sprout::detail::char_to_int<IntType>(*str, base ? base : 10),
negative negative
) )
; ;

View file

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

View file

@ -3,6 +3,6 @@
#include <cstddef> #include <cstddef>
#include <sprout/string/to_string.hpp> #include <sprout/string/to_string.hpp>
#include <sprout/string/from_strong.hpp> #include <sprout/string/from_string.hpp>
#endif // #ifndef SPROUT_STRING_CONVERSION_HPP #endif // #ifndef SPROUT_STRING_CONVERSION_HPP

View file

@ -1,7 +1,6 @@
#ifndef SPROUT_STRING_INT_TO_STRING_HPP #ifndef SPROUT_STRING_INT_TO_STRING_HPP
#define SPROUT_STRING_INT_TO_STRING_HPP #define SPROUT_STRING_INT_TO_STRING_HPP
#include <cstddef>
#include <type_traits> #include <type_traits>
#include <sprout/config.hpp> #include <sprout/config.hpp>
#include <sprout/string/string.hpp> #include <sprout/string/string.hpp>
@ -11,16 +10,26 @@
#include <sprout/detail/char_conversion.hpp> #include <sprout/detail/char_conversion.hpp>
namespace sprout { namespace sprout {
//
// printed_integer_digits
//
template<typename IntType, std::size_t Base = 10>
struct printed_integer_digits
: public std::integral_constant<
std::size_t,
sprout::integer_digits<IntType, Base>::value + (std::is_signed<IntType>::value ? 1 : 0)
>
{};
namespace detail { namespace detail {
template< template<
typename Elem, typename Elem,
std::size_t Base, int Base,
typename IntType, typename IntType,
typename... Args, typename... Args,
typename sprout::enabler_if<(sizeof...(Args) == sprout::integer_digits<IntType, Base>::value - 1)>::type = sprout::enabler typename sprout::enabler_if<(sizeof...(Args) == sprout::printed_integer_digits<IntType, Base>::value - 1)>::type = sprout::enabler
> >
inline SPROUT_CONSTEXPR sprout::basic_string<Elem, sprout::integer_digits<IntType, Base>::value> inline SPROUT_CONSTEXPR sprout::basic_string<Elem, sprout::printed_integer_digits<IntType, Base>::value>
int_to_string_impl_1(IntType val, bool negative, Args... args) { int_to_string_impl_1(IntType val, bool negative, Args... args) {
return negative ? sprout::make_string_as<Elem>(static_cast<Elem>('-'), args...) return negative ? sprout::make_string_as<Elem>(static_cast<Elem>('-'), args...)
: sprout::make_string_as<Elem>(args...) : sprout::make_string_as<Elem>(args...)
@ -28,12 +37,12 @@ namespace sprout {
} }
template< template<
typename Elem, typename Elem,
std::size_t Base, int Base,
typename IntType, typename IntType,
typename... Args, typename... Args,
typename sprout::enabler_if<(sizeof...(Args) < sprout::integer_digits<IntType, Base>::value - 1)>::type = sprout::enabler typename sprout::enabler_if<(sizeof...(Args) < sprout::printed_integer_digits<IntType, Base>::value - 1)>::type = sprout::enabler
> >
inline SPROUT_CONSTEXPR sprout::basic_string<Elem, sprout::integer_digits<IntType, Base>::value> inline SPROUT_CONSTEXPR sprout::basic_string<Elem, sprout::printed_integer_digits<IntType, Base>::value>
int_to_string_impl_1(IntType val, bool negative, Args... args) { int_to_string_impl_1(IntType val, bool negative, Args... args) {
return val == 0 return val == 0
? (negative ? sprout::make_string_as<Elem>(static_cast<Elem>('-'), args...) ? (negative ? sprout::make_string_as<Elem>(static_cast<Elem>('-'), args...)
@ -42,39 +51,38 @@ namespace sprout {
: sprout::detail::int_to_string_impl_1<Elem, Base>( : sprout::detail::int_to_string_impl_1<Elem, Base>(
val / Base, val / Base,
negative, negative,
sprout::detail::int_to_char<Elem>(val % Base, Base), sprout::detail::int_to_char<Elem>(negative ? -(val % Base) : val % Base, Base),
args... args...
) )
; ;
} }
template<typename Elem, std::size_t Base, typename IntType> template<typename Elem, int Base, typename IntType>
inline SPROUT_CONSTEXPR sprout::basic_string<Elem, sprout::integer_digits<IntType, Base>::value> inline SPROUT_CONSTEXPR sprout::basic_string<Elem, sprout::printed_integer_digits<IntType, Base>::value>
int_to_string_impl(IntType val) { int_to_string_impl(IntType val) {
return val == 0 ? sprout::make_string_as<Elem>(static_cast<Elem>('0')) return val == 0 ? sprout::make_string_as<Elem>(static_cast<Elem>('0'))
: val < 0 ? sprout::detail::int_to_string_impl_1<Elem, Base>(-val, true) : sprout::detail::int_to_string_impl_1<Elem, Base>(val, val < 0)
: sprout::detail::int_to_string_impl_1<Elem, Base>(val, false)
; ;
} }
template< template<
typename Elem, typename Elem,
std::size_t Base, int Base,
typename UIntType, typename UIntType,
typename... Args, typename... Args,
typename sprout::enabler_if<(sizeof...(Args) == sprout::integer_digits<UIntType, Base>::value)>::type = sprout::enabler typename sprout::enabler_if<(sizeof...(Args) == sprout::printed_integer_digits<UIntType, Base>::value)>::type = sprout::enabler
> >
inline SPROUT_CONSTEXPR sprout::basic_string<Elem, sprout::integer_digits<UIntType, Base>::value> inline SPROUT_CONSTEXPR sprout::basic_string<Elem, sprout::printed_integer_digits<UIntType, Base>::value>
uint_to_string_impl_1(UIntType val, Args... args) { uint_to_string_impl_1(UIntType val, Args... args) {
return sprout::make_string_as<Elem>(args...); return sprout::make_string_as<Elem>(args...);
} }
template< template<
typename Elem, typename Elem,
std::size_t Base, int Base,
typename UIntType, typename UIntType,
typename... Args, typename... Args,
typename sprout::enabler_if<(sizeof...(Args) < sprout::integer_digits<UIntType, Base>::value)>::type = sprout::enabler typename sprout::enabler_if<(sizeof...(Args) < sprout::printed_integer_digits<UIntType, Base>::value)>::type = sprout::enabler
> >
inline SPROUT_CONSTEXPR sprout::basic_string<Elem, sprout::integer_digits<UIntType, Base>::value> inline SPROUT_CONSTEXPR sprout::basic_string<Elem, sprout::printed_integer_digits<UIntType, Base>::value>
uint_to_string_impl_1(UIntType val, Args... args) { uint_to_string_impl_1(UIntType val, Args... args) {
return val == 0 return val == 0
? sprout::make_string_as<Elem>(args...) ? sprout::make_string_as<Elem>(args...)
@ -85,8 +93,8 @@ namespace sprout {
) )
; ;
} }
template<typename Elem, std::size_t Base, typename UIntType> template<typename Elem, int Base, typename UIntType>
inline SPROUT_CONSTEXPR sprout::basic_string<Elem, sprout::integer_digits<UIntType, Base>::value> inline SPROUT_CONSTEXPR sprout::basic_string<Elem, sprout::printed_integer_digits<UIntType, Base>::value>
uint_to_string_impl(UIntType val) { uint_to_string_impl(UIntType val) {
return val == 0 ? sprout::make_string_as<Elem>(static_cast<Elem>('0')) return val == 0 ? sprout::make_string_as<Elem>(static_cast<Elem>('0'))
: sprout::detail::uint_to_string_impl_1<Elem, Base>(val) : sprout::detail::uint_to_string_impl_1<Elem, Base>(val)
@ -95,21 +103,21 @@ namespace sprout {
template< template<
typename Elem, typename Elem,
std::size_t Base, int Base,
typename IntType, typename IntType,
typename sprout::enabler_if<std::is_signed<IntType>::value>::type = sprout::enabler typename sprout::enabler_if<std::is_signed<IntType>::value>::type = sprout::enabler
> >
inline SPROUT_CONSTEXPR sprout::basic_string<Elem, sprout::integer_digits<IntType, Base>::value> inline SPROUT_CONSTEXPR sprout::basic_string<Elem, sprout::printed_integer_digits<IntType, Base>::value>
int_to_string(IntType val) { int_to_string(IntType val) {
return sprout::detail::int_to_string_impl<Elem, Base>(val); return sprout::detail::int_to_string_impl<Elem, Base>(val);
} }
template< template<
typename Elem, typename Elem,
std::size_t Base, int Base,
typename IntType, typename IntType,
typename sprout::enabler_if<std::is_unsigned<IntType>::value>::type = sprout::enabler typename sprout::enabler_if<std::is_unsigned<IntType>::value>::type = sprout::enabler
> >
inline SPROUT_CONSTEXPR sprout::basic_string<Elem, sprout::integer_digits<IntType, Base>::value> inline SPROUT_CONSTEXPR sprout::basic_string<Elem, sprout::printed_integer_digits<IntType, Base>::value>
int_to_string(IntType val) { int_to_string(IntType val) {
return sprout::detail::uint_to_string_impl<Elem, Base>(val); return sprout::detail::uint_to_string_impl<Elem, Base>(val);
} }
@ -120,11 +128,11 @@ namespace sprout {
// //
template< template<
typename Elem, typename Elem,
std::size_t Base, int Base,
typename IntType, typename IntType,
typename sprout::enabler_if<std::is_integral<IntType>::value>::type = sprout::enabler typename sprout::enabler_if<std::is_integral<IntType>::value>::type = sprout::enabler
> >
inline SPROUT_CONSTEXPR sprout::basic_string<Elem, sprout::integer_digits<IntType, Base>::value> inline SPROUT_CONSTEXPR sprout::basic_string<Elem, sprout::printed_integer_digits<IntType, Base>::value>
int_to_string(IntType val) { int_to_string(IntType val) {
return sprout::detail::int_to_string<Elem, Base>(val); return sprout::detail::int_to_string<Elem, Base>(val);
} }
@ -133,7 +141,7 @@ namespace sprout {
// to_string_of // to_string_of
// //
template<typename Elem, typename IntType, typename sprout::enabler_if<std::is_integral<IntType>::value>::type = sprout::enabler> template<typename Elem, typename IntType, typename sprout::enabler_if<std::is_integral<IntType>::value>::type = sprout::enabler>
inline SPROUT_CONSTEXPR sprout::basic_string<Elem, sprout::integer_digits<IntType, 10>::value> inline SPROUT_CONSTEXPR sprout::basic_string<Elem, sprout::printed_integer_digits<IntType, 10>::value>
to_string_of(IntType val) { to_string_of(IntType val) {
return sprout::int_to_string<Elem, 10>(val); return sprout::int_to_string<Elem, 10>(val);
} }
@ -141,32 +149,32 @@ namespace sprout {
// //
// to_string // to_string
// //
inline SPROUT_CONSTEXPR sprout::basic_string<char, sprout::integer_digits<int>::value> inline SPROUT_CONSTEXPR sprout::basic_string<char, sprout::printed_integer_digits<int>::value>
to_string(int val) { to_string(int val) {
return sprout::to_string_of<char>(val); return sprout::to_string_of<char>(val);
} }
inline SPROUT_CONSTEXPR sprout::basic_string<char, sprout::integer_digits<unsigned>::value> inline SPROUT_CONSTEXPR sprout::basic_string<char, sprout::printed_integer_digits<unsigned>::value>
to_string(unsigned val) { to_string(unsigned val) {
return sprout::to_string_of<char>(val); return sprout::to_string_of<char>(val);
} }
inline SPROUT_CONSTEXPR sprout::basic_string<char, sprout::integer_digits<long>::value> inline SPROUT_CONSTEXPR sprout::basic_string<char, sprout::printed_integer_digits<long>::value>
to_string(long val) { to_string(long val) {
return sprout::to_string_of<char>(val); return sprout::to_string_of<char>(val);
} }
inline SPROUT_CONSTEXPR sprout::basic_string<char, sprout::integer_digits<unsigned long>::value> inline SPROUT_CONSTEXPR sprout::basic_string<char, sprout::printed_integer_digits<unsigned long>::value>
to_string(unsigned long val) { to_string(unsigned long val) {
return sprout::to_string_of<char>(val); return sprout::to_string_of<char>(val);
} }
inline SPROUT_CONSTEXPR sprout::basic_string<char, sprout::integer_digits<long long>::value> inline SPROUT_CONSTEXPR sprout::basic_string<char, sprout::printed_integer_digits<long long>::value>
to_string(long long val) { to_string(long long val) {
return sprout::to_string_of<char>(val); return sprout::to_string_of<char>(val);
} }
inline SPROUT_CONSTEXPR sprout::basic_string<char, sprout::integer_digits<unsigned long long>::value> inline SPROUT_CONSTEXPR sprout::basic_string<char, sprout::printed_integer_digits<unsigned long long>::value>
to_string(unsigned long long val) { to_string(unsigned long long val) {
return sprout::to_string_of<char>(val); return sprout::to_string_of<char>(val);
} }
template<typename IntType, typename sprout::enabler_if<std::is_integral<IntType>::value>::type = sprout::enabler> template<typename IntType, typename sprout::enabler_if<std::is_integral<IntType>::value>::type = sprout::enabler>
inline SPROUT_CONSTEXPR sprout::basic_string<char, sprout::integer_digits<IntType>::value> inline SPROUT_CONSTEXPR sprout::basic_string<char, sprout::printed_integer_digits<IntType>::value>
to_string(IntType val) { to_string(IntType val) {
return sprout::to_string_of<char>(val); return sprout::to_string_of<char>(val);
} }
@ -174,32 +182,32 @@ namespace sprout {
// //
// to_wstring // to_wstring
// //
inline SPROUT_CONSTEXPR sprout::basic_string<wchar_t, sprout::integer_digits<int>::value> inline SPROUT_CONSTEXPR sprout::basic_string<wchar_t, sprout::printed_integer_digits<int>::value>
to_wstring(int val) { to_wstring(int val) {
return sprout::to_string_of<wchar_t>(val); return sprout::to_string_of<wchar_t>(val);
} }
inline SPROUT_CONSTEXPR sprout::basic_string<wchar_t, sprout::integer_digits<unsigned>::value> inline SPROUT_CONSTEXPR sprout::basic_string<wchar_t, sprout::printed_integer_digits<unsigned>::value>
to_wstring(unsigned val) { to_wstring(unsigned val) {
return sprout::to_string_of<wchar_t>(val); return sprout::to_string_of<wchar_t>(val);
} }
inline SPROUT_CONSTEXPR sprout::basic_string<wchar_t, sprout::integer_digits<long>::value> inline SPROUT_CONSTEXPR sprout::basic_string<wchar_t, sprout::printed_integer_digits<long>::value>
to_wstring(long val) { to_wstring(long val) {
return sprout::to_string_of<wchar_t>(val); return sprout::to_string_of<wchar_t>(val);
} }
inline SPROUT_CONSTEXPR sprout::basic_string<wchar_t, sprout::integer_digits<unsigned long>::value> inline SPROUT_CONSTEXPR sprout::basic_string<wchar_t, sprout::printed_integer_digits<unsigned long>::value>
to_wstring(unsigned long val) { to_wstring(unsigned long val) {
return sprout::to_string_of<wchar_t>(val); return sprout::to_string_of<wchar_t>(val);
} }
inline SPROUT_CONSTEXPR sprout::basic_string<wchar_t, sprout::integer_digits<long long>::value> inline SPROUT_CONSTEXPR sprout::basic_string<wchar_t, sprout::printed_integer_digits<long long>::value>
to_wstring(long long val) { to_wstring(long long val) {
return sprout::to_string_of<wchar_t>(val); return sprout::to_string_of<wchar_t>(val);
} }
inline SPROUT_CONSTEXPR sprout::basic_string<wchar_t, sprout::integer_digits<unsigned long long>::value> inline SPROUT_CONSTEXPR sprout::basic_string<wchar_t, sprout::printed_integer_digits<unsigned long long>::value>
to_wstring(unsigned long long val) { to_wstring(unsigned long long val) {
return sprout::to_string_of<wchar_t>(val); return sprout::to_string_of<wchar_t>(val);
} }
template<typename IntType, typename sprout::enabler_if<std::is_integral<IntType>::value>::type = sprout::enabler> template<typename IntType, typename sprout::enabler_if<std::is_integral<IntType>::value>::type = sprout::enabler>
inline SPROUT_CONSTEXPR sprout::basic_string<wchar_t, sprout::integer_digits<IntType>::value> inline SPROUT_CONSTEXPR sprout::basic_string<wchar_t, sprout::printed_integer_digits<IntType>::value>
to_wstring(IntType val) { to_wstring(IntType val) {
return sprout::to_string_of<wchar_t>(val); return sprout::to_string_of<wchar_t>(val);
} }
@ -207,32 +215,32 @@ namespace sprout {
// //
// to_u16string // to_u16string
// //
inline SPROUT_CONSTEXPR sprout::basic_string<char16_t, sprout::integer_digits<int>::value> inline SPROUT_CONSTEXPR sprout::basic_string<char16_t, sprout::printed_integer_digits<int>::value>
to_u16string(int val) { to_u16string(int val) {
return sprout::to_string_of<char16_t>(val); return sprout::to_string_of<char16_t>(val);
} }
inline SPROUT_CONSTEXPR sprout::basic_string<char16_t, sprout::integer_digits<unsigned>::value> inline SPROUT_CONSTEXPR sprout::basic_string<char16_t, sprout::printed_integer_digits<unsigned>::value>
to_u16string(unsigned val) { to_u16string(unsigned val) {
return sprout::to_string_of<char16_t>(val); return sprout::to_string_of<char16_t>(val);
} }
inline SPROUT_CONSTEXPR sprout::basic_string<char16_t, sprout::integer_digits<long>::value> inline SPROUT_CONSTEXPR sprout::basic_string<char16_t, sprout::printed_integer_digits<long>::value>
to_u16string(long val) { to_u16string(long val) {
return sprout::to_string_of<char16_t>(val); return sprout::to_string_of<char16_t>(val);
} }
inline SPROUT_CONSTEXPR sprout::basic_string<char16_t, sprout::integer_digits<unsigned long>::value> inline SPROUT_CONSTEXPR sprout::basic_string<char16_t, sprout::printed_integer_digits<unsigned long>::value>
to_u16string(unsigned long val) { to_u16string(unsigned long val) {
return sprout::to_string_of<char16_t>(val); return sprout::to_string_of<char16_t>(val);
} }
inline SPROUT_CONSTEXPR sprout::basic_string<char16_t, sprout::integer_digits<long long>::value> inline SPROUT_CONSTEXPR sprout::basic_string<char16_t, sprout::printed_integer_digits<long long>::value>
to_u16string(long long val) { to_u16string(long long val) {
return sprout::to_string_of<char16_t>(val); return sprout::to_string_of<char16_t>(val);
} }
inline SPROUT_CONSTEXPR sprout::basic_string<char16_t, sprout::integer_digits<unsigned long long>::value> inline SPROUT_CONSTEXPR sprout::basic_string<char16_t, sprout::printed_integer_digits<unsigned long long>::value>
to_u16string(unsigned long long val) { to_u16string(unsigned long long val) {
return sprout::to_string_of<char16_t>(val); return sprout::to_string_of<char16_t>(val);
} }
template<typename IntType, typename sprout::enabler_if<std::is_integral<IntType>::value>::type = sprout::enabler> template<typename IntType, typename sprout::enabler_if<std::is_integral<IntType>::value>::type = sprout::enabler>
inline SPROUT_CONSTEXPR sprout::basic_string<char16_t, sprout::integer_digits<IntType>::value> inline SPROUT_CONSTEXPR sprout::basic_string<char16_t, sprout::printed_integer_digits<IntType>::value>
to_u16string(IntType val) { to_u16string(IntType val) {
return sprout::to_string_of<char16_t>(val); return sprout::to_string_of<char16_t>(val);
} }
@ -240,32 +248,32 @@ namespace sprout {
// //
// to_u32string // to_u32string
// //
inline SPROUT_CONSTEXPR sprout::basic_string<char32_t, sprout::integer_digits<int>::value> inline SPROUT_CONSTEXPR sprout::basic_string<char32_t, sprout::printed_integer_digits<int>::value>
to_u32string(int val) { to_u32string(int val) {
return sprout::to_string_of<char32_t>(val); return sprout::to_string_of<char32_t>(val);
} }
inline SPROUT_CONSTEXPR sprout::basic_string<char32_t, sprout::integer_digits<unsigned>::value> inline SPROUT_CONSTEXPR sprout::basic_string<char32_t, sprout::printed_integer_digits<unsigned>::value>
to_u32string(unsigned val) { to_u32string(unsigned val) {
return sprout::to_string_of<char32_t>(val); return sprout::to_string_of<char32_t>(val);
} }
inline SPROUT_CONSTEXPR sprout::basic_string<char32_t, sprout::integer_digits<long>::value> inline SPROUT_CONSTEXPR sprout::basic_string<char32_t, sprout::printed_integer_digits<long>::value>
to_u32string(long val) { to_u32string(long val) {
return sprout::to_string_of<char32_t>(val); return sprout::to_string_of<char32_t>(val);
} }
inline SPROUT_CONSTEXPR sprout::basic_string<char32_t, sprout::integer_digits<unsigned long>::value> inline SPROUT_CONSTEXPR sprout::basic_string<char32_t, sprout::printed_integer_digits<unsigned long>::value>
to_u32string(unsigned long val) { to_u32string(unsigned long val) {
return sprout::to_string_of<char32_t>(val); return sprout::to_string_of<char32_t>(val);
} }
inline SPROUT_CONSTEXPR sprout::basic_string<char32_t, sprout::integer_digits<long long>::value> inline SPROUT_CONSTEXPR sprout::basic_string<char32_t, sprout::printed_integer_digits<long long>::value>
to_u32string(long long val) { to_u32string(long long val) {
return sprout::to_string_of<char32_t>(val); return sprout::to_string_of<char32_t>(val);
} }
inline SPROUT_CONSTEXPR sprout::basic_string<char32_t, sprout::integer_digits<unsigned long long>::value> inline SPROUT_CONSTEXPR sprout::basic_string<char32_t, sprout::printed_integer_digits<unsigned long long>::value>
to_u32string(unsigned long long val) { to_u32string(unsigned long long val) {
return sprout::to_string_of<char32_t>(val); return sprout::to_string_of<char32_t>(val);
} }
template<typename IntType, typename sprout::enabler_if<std::is_integral<IntType>::value>::type = sprout::enabler> template<typename IntType, typename sprout::enabler_if<std::is_integral<IntType>::value>::type = sprout::enabler>
inline SPROUT_CONSTEXPR sprout::basic_string<char32_t, sprout::integer_digits<IntType>::value> inline SPROUT_CONSTEXPR sprout::basic_string<char32_t, sprout::printed_integer_digits<IntType>::value>
to_u32string(IntType val) { to_u32string(IntType val) {
return sprout::to_string_of<char32_t>(val); return sprout::to_string_of<char32_t>(val);
} }

View file

@ -122,7 +122,7 @@ namespace sprout {
typename sprout::enabler_if<std::is_integral<IntType>::value>::type = sprout::enabler typename sprout::enabler_if<std::is_integral<IntType>::value>::type = sprout::enabler
> >
inline SPROUT_CONSTEXPR IntType from_string(sprout::basic_string<Elem, N, Traits> const& str, std::size_t* idx) { inline SPROUT_CONSTEXPR IntType from_string(sprout::basic_string<Elem, N, Traits> const& str, std::size_t* idx) {
return sprout::string_to_int<IntType>(str, idx); return sprout::string_to_int<IntType>(str, idx, 0);
} }
template< template<
typename IntType, typename IntType,
@ -132,7 +132,7 @@ namespace sprout {
typename sprout::enabler_if<std::is_integral<IntType>::value>::type = sprout::enabler typename sprout::enabler_if<std::is_integral<IntType>::value>::type = sprout::enabler
> >
inline SPROUT_CONSTEXPR IntType from_string(sprout::basic_string<Elem, N, Traits> const& str) { inline SPROUT_CONSTEXPR IntType from_string(sprout::basic_string<Elem, N, Traits> const& str) {
return sprout::string_to_int<IntType>(str); return sprout::string_to_int<IntType>(str, 0);
} }
} // namespace sprout } // namespace sprout