mirror of
https://github.com/boostorg/multiprecision.git
synced 2026-02-14 00:42:53 +00:00
Cast std::string::size_type arguments to std::string functions so there can be no ambiguity in the calls, see https://svn.boost.org/trac/boost/ticket/11029
This commit is contained in:
@@ -496,7 +496,7 @@ std::string cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::s
|
||||
// Fixed precision, no significant digits, and nothing to round!
|
||||
s = "0";
|
||||
if(sign())
|
||||
s.insert(0, 1, '-');
|
||||
s.insert(static_cast<std::string::size_type>(0), 1, '-');
|
||||
boost::multiprecision::detail::format_float_string(s, base10_exp, dig, f, true);
|
||||
return s;
|
||||
}
|
||||
@@ -661,7 +661,7 @@ std::string cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::s
|
||||
}
|
||||
|
||||
if(sign())
|
||||
s.insert(0, 1, '-');
|
||||
s.insert(static_cast<std::string::size_type>(0), 1, '-');
|
||||
|
||||
boost::multiprecision::detail::format_float_string(s, base10_exp, dig, f, false);
|
||||
}
|
||||
|
||||
@@ -1775,7 +1775,7 @@ std::string cpp_dec_float<Digits10, ExponentType, Allocator>::str(boost::intmax_
|
||||
// We only get here if the output format is "fixed" and we just need to
|
||||
// round the first non-zero digit.
|
||||
number_of_digits -= my_exp + 1; // reset to original value
|
||||
str.insert(0, std::string::size_type(number_of_digits), '0');
|
||||
str.insert(static_cast<std::string::size_type>(0), std::string::size_type(number_of_digits), '0');
|
||||
have_leading_zeros = true;
|
||||
}
|
||||
|
||||
@@ -1783,7 +1783,7 @@ std::string cpp_dec_float<Digits10, ExponentType, Allocator>::str(boost::intmax_
|
||||
{
|
||||
str = "0";
|
||||
if(isneg())
|
||||
str.insert(0, 1, '-');
|
||||
str.insert(static_cast<std::string::size_type>(0), 1, '-');
|
||||
boost::multiprecision::detail::format_float_string(str, 0, number_of_digits - my_exp - 1, f, this->iszero());
|
||||
return str;
|
||||
}
|
||||
@@ -1874,7 +1874,7 @@ std::string cpp_dec_float<Digits10, ExponentType, Allocator>::str(boost::intmax_
|
||||
}
|
||||
|
||||
if(isneg())
|
||||
str.insert(0, 1, '-');
|
||||
str.insert(static_cast<std::string::size_type>(0), 1, '-');
|
||||
|
||||
boost::multiprecision::detail::format_float_string(str, my_exp, org_digits, f, this->iszero());
|
||||
return str;
|
||||
@@ -2001,7 +2001,7 @@ bool cpp_dec_float<Digits10, ExponentType, Allocator>::rd_string(const char* con
|
||||
|
||||
// Bring one single digit into the mantissa and adjust the exponent accordingly.
|
||||
str.erase(str.begin(), it_non_zero);
|
||||
str.insert(static_cast<std::size_t>(1u), ".");
|
||||
str.insert(static_cast<std::string::size_type>(1u), ".");
|
||||
exp -= static_cast<ExponentType>(delta_exp + 1u);
|
||||
}
|
||||
}
|
||||
@@ -2037,9 +2037,9 @@ bool cpp_dec_float<Digits10, ExponentType, Allocator>::rd_string(const char* con
|
||||
// Do the decimal point shift.
|
||||
if(n_shift != static_cast<std::size_t>(0u))
|
||||
{
|
||||
str.insert(static_cast<std::size_t>(pos_plus_one + n_shift), ".");
|
||||
str.insert(static_cast<std::string::size_type>(pos_plus_one + n_shift), ".");
|
||||
|
||||
str.erase(pos, static_cast<std::size_t>(1u));
|
||||
str.erase(pos, static_cast<std::string::size_type>(1u));
|
||||
|
||||
exp -= static_cast<ExponentType>(n_shift);
|
||||
}
|
||||
|
||||
@@ -1491,7 +1491,7 @@ private:
|
||||
if(f & std::ios_base::showbase)
|
||||
{
|
||||
const char* pp = base == 8 ? "0" : "0x";
|
||||
result.insert(0, pp);
|
||||
result.insert(static_cast<std::string::size_type>(0), pp);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -1515,9 +1515,9 @@ private:
|
||||
if(result.empty())
|
||||
result = "0";
|
||||
if(neg)
|
||||
result.insert(0, 1, '-');
|
||||
result.insert(static_cast<std::string::size_type>(0), 1, '-');
|
||||
else if(f & std::ios_base::showpos)
|
||||
result.insert(0, 1, '+');
|
||||
result.insert(static_cast<std::string::size_type>(0), 1, '+');
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -1576,7 +1576,7 @@ private:
|
||||
if(f & std::ios_base::showbase)
|
||||
{
|
||||
const char* pp = base == 8 ? "0" : "0x";
|
||||
result.insert(0, pp);
|
||||
result.insert(static_cast<std::string::size_type>(0), pp);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -1620,9 +1620,9 @@ private:
|
||||
if(result.empty())
|
||||
result = "0";
|
||||
if(neg)
|
||||
result.insert(0, 1, '-');
|
||||
result.insert(static_cast<std::string::size_type>(0), 1, '-');
|
||||
else if(f & std::ios_base::showpos)
|
||||
result.insert(0, 1, '+');
|
||||
result.insert(static_cast<std::string::size_type>(0), 1, '+');
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ inline void round_string_up_at(std::string& s, int pos, I& expon)
|
||||
//
|
||||
if(pos < 0)
|
||||
{
|
||||
s.insert(0, 1, '1');
|
||||
s.insert(static_cast<std::string::size_type>(0), 1, '1');
|
||||
s.erase(s.size() - 1);
|
||||
++expon;
|
||||
}
|
||||
@@ -182,7 +182,7 @@ std::string convert_to_string(Backend b, std::streamsize digits, std::ios_base::
|
||||
}
|
||||
BOOST_ASSERT(org_digits >= 0);
|
||||
if(isneg)
|
||||
result.insert(0, 1, '-');
|
||||
result.insert(static_cast<std::string::size_type>(0), 1, '-');
|
||||
format_float_string(result, expon, org_digits, f, iszero);
|
||||
|
||||
return result;
|
||||
|
||||
@@ -618,9 +618,9 @@ void format_float_string(S& str, boost::intmax_t my_exp, boost::intmax_t digits,
|
||||
}
|
||||
}
|
||||
if(neg)
|
||||
str.insert(0, 1, '-');
|
||||
str.insert(static_cast<std::string::size_type>(0), 1, '-');
|
||||
else if(showpos)
|
||||
str.insert(0, 1, '+');
|
||||
str.insert(static_cast<std::string::size_type>(0), 1, '+');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -665,8 +665,8 @@ void format_float_string(S& str, boost::intmax_t my_exp, boost::intmax_t digits,
|
||||
{
|
||||
if(my_exp < 0)
|
||||
{
|
||||
str.insert(0, static_cast<std::string::size_type>(-1 - my_exp), '0');
|
||||
str.insert(0, "0.");
|
||||
str.insert(static_cast<std::string::size_type>(0), static_cast<std::string::size_type>(-1 - my_exp), '0');
|
||||
str.insert(static_cast<std::string::size_type>(0), "0.");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -691,21 +691,21 @@ void format_float_string(S& str, boost::intmax_t my_exp, boost::intmax_t digits,
|
||||
BOOST_MP_USING_ABS
|
||||
// Scientific format:
|
||||
if(showpoint || (str.size() > 1))
|
||||
str.insert(1, 1, '.');
|
||||
str.append(1, 'e');
|
||||
str.insert(static_cast<std::string::size_type>(1u), 1, '.');
|
||||
str.append(static_cast<std::string::size_type>(1u), 'e');
|
||||
S e = boost::lexical_cast<S>(abs(my_exp));
|
||||
if(e.size() < BOOST_MP_MIN_EXPONENT_DIGITS)
|
||||
e.insert(0, BOOST_MP_MIN_EXPONENT_DIGITS-e.size(), '0');
|
||||
e.insert(static_cast<std::string::size_type>(0), BOOST_MP_MIN_EXPONENT_DIGITS - e.size(), '0');
|
||||
if(my_exp < 0)
|
||||
e.insert(0, 1, '-');
|
||||
e.insert(static_cast<std::string::size_type>(0), 1, '-');
|
||||
else
|
||||
e.insert(0, 1, '+');
|
||||
e.insert(static_cast<std::string::size_type>(0), 1, '+');
|
||||
str.append(e);
|
||||
}
|
||||
if(neg)
|
||||
str.insert(0, 1, '-');
|
||||
str.insert(static_cast<std::string::size_type>(0), 1, '-');
|
||||
else if(showpos)
|
||||
str.insert(0, 1, '+');
|
||||
str.insert(static_cast<std::string::size_type>(0), 1, '+');
|
||||
}
|
||||
|
||||
template <class V>
|
||||
|
||||
@@ -1216,10 +1216,10 @@ struct gmp_int
|
||||
{
|
||||
int pos = s[0] == '-' ? 1 : 0;
|
||||
const char* pp = base == 8 ? "0" : "0x";
|
||||
s.insert(pos, pp);
|
||||
s.insert(static_cast<std::string::size_type>(pos), pp);
|
||||
}
|
||||
if((f & std::ios_base::showpos) && (s[0] != '-'))
|
||||
s.insert(0, 1, '+');
|
||||
s.insert(static_cast<std::string::size_type>(0), 1, '+');
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
@@ -1692,7 +1692,7 @@ inline std::ostream& operator << (std::ostream& os, const number<Backend, Expres
|
||||
if((os.flags() & std::ios_base::left) == std::ios_base::left)
|
||||
s.append(static_cast<std::string::size_type>(ss - s.size()), fill);
|
||||
else
|
||||
s.insert(0, static_cast<std::string::size_type>(ss - s.size()), fill);
|
||||
s.insert(static_cast<std::string::size_type>(0), static_cast<std::string::size_type>(ss - s.size()), fill);
|
||||
}
|
||||
return os << s;
|
||||
}
|
||||
@@ -1754,9 +1754,9 @@ inline std::istream& operator >> (std::istream& is, rational<multiprecision::num
|
||||
is.get();
|
||||
}
|
||||
if(hex_format && ((s1[0] != '0') || (s1[1] != 'x')))
|
||||
s1.insert(0, "0x");
|
||||
s1.insert(static_cast<std::string::size_type>(0), "0x");
|
||||
if(oct_format && (s1[0] != '0'))
|
||||
s1.insert(0, "0");
|
||||
s1.insert(static_cast<std::string::size_type>(0), "0");
|
||||
v1.assign(s1);
|
||||
s1.erase();
|
||||
if(c == '/')
|
||||
@@ -1770,9 +1770,9 @@ inline std::istream& operator >> (std::istream& is, rational<multiprecision::num
|
||||
is.get();
|
||||
}
|
||||
if(hex_format && ((s1[0] != '0') || (s1[1] != 'x')))
|
||||
s1.insert(0, "0x");
|
||||
s1.insert(static_cast<std::string::size_type>(0), "0x");
|
||||
if(oct_format && (s1[0] != '0'))
|
||||
s1.insert(0, "0");
|
||||
s1.insert(static_cast<std::string::size_type>(0), "0");
|
||||
v2.assign(s1);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -314,10 +314,10 @@ struct tommath_int
|
||||
{
|
||||
int pos = result[0] == '-' ? 1 : 0;
|
||||
const char* pp = base == 8 ? "0" : "0x";
|
||||
result.insert(pos, pp);
|
||||
result.insert(static_cast<std::string::size_type>(pos), pp);
|
||||
}
|
||||
if((f & std::ios_base::showpos) && (result[0] != '-'))
|
||||
result.insert(0, 1, '+');
|
||||
result.insert(static_cast<std::string::size_type>(0), 1, '+');
|
||||
return result;
|
||||
}
|
||||
~tommath_int()
|
||||
|
||||
Reference in New Issue
Block a user