diff options
Diffstat (limited to 'boost/convert/strtol.hpp')
-rw-r--r-- | boost/convert/strtol.hpp | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/boost/convert/strtol.hpp b/boost/convert/strtol.hpp index bc329c6870..5d10bde5a7 100644 --- a/boost/convert/strtol.hpp +++ b/boost/convert/strtol.hpp @@ -55,15 +55,21 @@ struct boost::cnv::strtol : public boost::cnv::cnvbase<boost::cnv::strtol> template<typename string_type> void str_to(cnv::range<string_type> v, optional< int_type>& r) const { str_to_i (v, r); } template<typename string_type> void str_to(cnv::range<string_type> v, optional< sint_type>& r) const { str_to_i (v, r); } template<typename string_type> void str_to(cnv::range<string_type> v, optional< lint_type>& r) const { str_to_i (v, r); } + template<typename string_type> void str_to(cnv::range<string_type> v, optional< llint_type>& r) const { str_to_i (v, r); } template<typename string_type> void str_to(cnv::range<string_type> v, optional< uint_type>& r) const { str_to_i (v, r); } template<typename string_type> void str_to(cnv::range<string_type> v, optional< usint_type>& r) const { str_to_i (v, r); } template<typename string_type> void str_to(cnv::range<string_type> v, optional< ulint_type>& r) const { str_to_i (v, r); } + template<typename string_type> void str_to(cnv::range<string_type> v, optional<ullint_type>& r) const { str_to_i (v, r); } template<typename string_type> void str_to(cnv::range<string_type> v, optional< flt_type>& r) const { str_to_d (v, r); } template<typename string_type> void str_to(cnv::range<string_type> v, optional< dbl_type>& r) const { str_to_d (v, r); } template<typename string_type> void str_to(cnv::range<string_type> v, optional< ldbl_type>& r) const { str_to_d (v, r); } - template <typename char_type> cnv::range<char_type*> to_str ( int_type v, char_type* buf) const { return i_to_str(v, buf); } - template <typename char_type> cnv::range<char_type*> to_str (lint_type v, char_type* buf) const { return i_to_str(v, buf); } + template <typename char_type> cnv::range<char_type*> to_str ( int_type v, char_type* buf) const { return i_to_str(v, buf); } + template <typename char_type> cnv::range<char_type*> to_str ( uint_type v, char_type* buf) const { return i_to_str(v, buf); } + template <typename char_type> cnv::range<char_type*> to_str ( lint_type v, char_type* buf) const { return i_to_str(v, buf); } + template <typename char_type> cnv::range<char_type*> to_str ( ulint_type v, char_type* buf) const { return i_to_str(v, buf); } + template <typename char_type> cnv::range<char_type*> to_str ( llint_type v, char_type* buf) const { return i_to_str(v, buf); } + template <typename char_type> cnv::range<char_type*> to_str (ullint_type v, char_type* buf) const { return i_to_str(v, buf); } template <typename char_type> cnv::range<char_type*> to_str ( dbl_type v, char_type* buf) const; template<typename char_type, typename in_type> cnv::range<char_type*> i_to_str (in_type, char_type*) const; @@ -76,13 +82,16 @@ struct boost::cnv::strtol : public boost::cnv::cnvbase<boost::cnv::strtol> template<typename char_type, typename Type> boost::cnv::range<char_type*> -boost::cnv::strtol::i_to_str(Type value, char_type* buf) const +boost::cnv::strtol::i_to_str(Type in_value, char_type* buf) const { // C1. Base=10 optimization improves performance 10% + typedef typename boost::make_unsigned<Type>::type unsigned_type; + char_type* beg = buf + bufsize_ / 2; char_type* end = beg; - bool const is_negative = (value < 0) ? (value = -value, true) : false; + bool const is_negative = in_value < 0; + unsigned_type value = static_cast<unsigned_type>(is_negative ? -in_value : in_value); if (base_ == 10) for (; value; *(--beg) = int(value % 10) + '0', value /= 10); //C1 else for (; value; *(--beg) = get_char(value % base_), value /= base_); @@ -160,7 +169,6 @@ template<typename string_type, typename out_type> void boost::cnv::strtol::str_to_i(cnv::range<string_type> range, boost::optional<out_type>& result_out) const { - typedef typename boost::make_unsigned<out_type>::type unsigned_type; typedef cnv::range<string_type> range_type; typedef typename range_type::iterator iterator; @@ -182,7 +190,7 @@ boost::cnv::strtol::str_to_i(cnv::range<string_type> range, boost::optional<out_ for (; s != range.sentry(); ++s) { - unsigned int ch = *s; + ch = *s; /**/ if (std::isdigit(ch)) ch -= '0'; else if (std::isalpha(ch)) ch -= (std::isupper(ch) ? 'A' : 'a') - 10; @@ -202,7 +210,6 @@ void boost::cnv::strtol::str_to_d(cnv::range<string_type> range, optional<out_type>& result_out) const { typedef cnv::range<string_type> range_type; - typedef typename range_type::iterator iterator; typedef typename range_type::value_type char_type; char_type const* str = &*range.begin(); // Currently only works with 'char' |