]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/boost/boost/convert/strtol.hpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / boost / convert / strtol.hpp
index 4dd26eef7f33b5c840aa48cdd687dec62ca47f05..a762bba34534b4d0cfea4f47d23842e22e900376 100644 (file)
@@ -80,9 +80,10 @@ boost::cnv::strtol::i_to_str(Type in_value, char_type* buf) const
     char_type*      end = beg;
     bool const   is_neg = std::is_signed<Type>::value && in_value < 0;
     unsigned_type value = static_cast<unsigned_type>(is_neg ? -in_value : in_value);
+    int            base = int(base_);
 
-    if (base_ == 10) for (; value; *(--beg) = int(value % 10) + '0', value /= 10); //C1
-    else             for (; value; *(--beg) = get_char(value % base_), value /= base_);
+    if (base == 10) for (; value; *(--beg) = int(value % 10) + '0', value /= 10); //C1
+    else            for (; value; *(--beg) = get_char(value % base), value /= base);
 
     if (beg == end) *(--beg) = '0';
     if (is_neg)     *(--beg) = '-';
@@ -157,23 +158,25 @@ 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;
+    using     uint_type = unsigned int;
+    using unsigned_type = typename boost::make_unsigned<out_type>::type;
+    using    range_type = cnv::range<string_type>;
+    using      iterator = typename range_type::iterator;
 
     iterator             s = range.begin();
-    unsigned int        ch = *s;
+    uint_type           ch = *s;
     bool const is_negative = ch == '-' ? (ch = *++s, true) : ch == '+' ? (ch = *++s, false) : false;
     bool const is_unsigned = boost::is_same<out_type, unsigned_type>::value;
-    unsigned int      base = base_;
+    uint_type         base = uint_type(base_);
 
     /**/ if (is_negative && is_unsigned) return;
     else if ((base == 0 || base == 16) && ch == '0' && (*++s == 'x' || *s == 'X')) ++s, base = 16;
     else if (base == 0) base = ch == '0' ? (++s, 8) : 10;
 
-    unsigned_type const    max = (std::numeric_limits<out_type>::max)() + (is_negative ? 1 : 0);
-    unsigned_type const cutoff = max / base;
-    unsigned int  const cutlim = max % base;
+    unsigned_type const    max = (std::numeric_limits<out_type>::max)();
+    unsigned_type const   umax = max + (is_negative ? 1 : 0);
+    unsigned_type const cutoff = umax / base;
+    uint_type     const cutlim = umax % base;
     unsigned_type       result = 0;
 
     for (; s != range.sentry(); ++s)
@@ -206,7 +209,7 @@ boost::cnv::strtol::str_to_d(cnv::range<string_type> range, optional<out_type>&
     typedef typename range_type::value_type ch_type;
 
     size_t const  sz = 128;
-    ch_type  str[sz] = {0}; std::strncpy(str, &*range.begin(), std::min(sz - 1, range.size()));
+    ch_type  str[sz] = {0}; std::strncpy(str, &*range.begin(), (std::min)(sz - 1, range.size()));
     char*    cnv_end = 0;
     ldbl_type result = strtold(str, &cnv_end);
     bool        good = result != -HUGE_VALL && result != HUGE_VALL && *cnv_end == 0; //C3