update boost
This commit is contained in:
@@ -40,7 +40,7 @@ namespace boost { namespace spirit { namespace karma
|
||||
call (OutputIterator& sink, U b, Policies const& p = Policies())
|
||||
{
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1600))
|
||||
p; // suppresses warning: C4100: 'p' : unreferenced formal parameter
|
||||
(void)p; // suppresses warning: C4100: 'p' : unreferenced formal parameter
|
||||
#endif
|
||||
return p.template call<bool_inserter>(sink, T(b), p);
|
||||
}
|
||||
@@ -53,7 +53,7 @@ namespace boost { namespace spirit { namespace karma
|
||||
call_n (OutputIterator& sink, U b, Policies const& p)
|
||||
{
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1600))
|
||||
p; // suppresses warning: C4100: 'p' : unreferenced formal parameter
|
||||
(void)p; // suppresses warning: C4100: 'p' : unreferenced formal parameter
|
||||
#endif
|
||||
if (b)
|
||||
return p.template generate_true<CharEncoding, Tag>(sink, b);
|
||||
|
||||
@@ -14,16 +14,16 @@
|
||||
#include <boost/config/no_tr1/cmath.hpp>
|
||||
#include <boost/limits.hpp>
|
||||
|
||||
#include <boost/math/special_functions/fpclassify.hpp>
|
||||
#include <boost/type_traits/is_integral.hpp>
|
||||
#include <boost/spirit/home/support/char_class.hpp>
|
||||
#include <boost/spirit/home/support/unused.hpp>
|
||||
#include <boost/spirit/home/support/numeric_traits.hpp>
|
||||
#include <boost/spirit/home/support/detail/pow10.hpp>
|
||||
#include <boost/spirit/home/support/detail/sign.hpp>
|
||||
#include <boost/spirit/home/karma/detail/generate_to.hpp>
|
||||
#include <boost/spirit/home/karma/detail/string_generate.hpp>
|
||||
|
||||
#include <boost/core/cmath.hpp>
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// The value BOOST_KARMA_NUMERICS_LOOP_UNROLL specifies, how to unroll the
|
||||
@@ -120,7 +120,7 @@ namespace boost { namespace spirit { namespace traits
|
||||
typedef float type;
|
||||
static type call(float n)
|
||||
{
|
||||
return (spirit::detail::signbit)(n) ? -n : n;
|
||||
return (std::fabs)(n);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -130,7 +130,7 @@ namespace boost { namespace spirit { namespace traits
|
||||
typedef double type;
|
||||
static type call(double n)
|
||||
{
|
||||
return (spirit::detail::signbit)(n) ? -n : n;
|
||||
return (std::fabs)(n);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -140,7 +140,7 @@ namespace boost { namespace spirit { namespace traits
|
||||
typedef long double type;
|
||||
static type call(long double n)
|
||||
{
|
||||
return (spirit::detail::signbit)(n) ? -n : n;
|
||||
return (std::fabs)(n);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -177,7 +177,7 @@ namespace boost { namespace spirit { namespace traits
|
||||
{
|
||||
static bool call(float n)
|
||||
{
|
||||
return (spirit::detail::signbit)(n) ? true : false;
|
||||
return (core::signbit)(n) ? true : false;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -186,7 +186,7 @@ namespace boost { namespace spirit { namespace traits
|
||||
{
|
||||
static bool call(double n)
|
||||
{
|
||||
return (spirit::detail::signbit)(n) ? true : false;
|
||||
return (core::signbit)(n) ? true : false;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -195,7 +195,7 @@ namespace boost { namespace spirit { namespace traits
|
||||
{
|
||||
static bool call(long double n)
|
||||
{
|
||||
return (spirit::detail::signbit)(n) ? true : false;
|
||||
return (core::signbit)(n) ? true : false;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -220,7 +220,7 @@ namespace boost { namespace spirit { namespace traits
|
||||
{
|
||||
static bool call(float n)
|
||||
{
|
||||
return (math::fpclassify)(n) == FP_ZERO;
|
||||
return (core::fpclassify)(n) == core::fp_zero;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -229,7 +229,7 @@ namespace boost { namespace spirit { namespace traits
|
||||
{
|
||||
static bool call(double n)
|
||||
{
|
||||
return (math::fpclassify)(n) == FP_ZERO;
|
||||
return (core::fpclassify)(n) == core::fp_zero;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -238,7 +238,7 @@ namespace boost { namespace spirit { namespace traits
|
||||
{
|
||||
static bool call(long double n)
|
||||
{
|
||||
return (math::fpclassify)(n) == FP_ZERO;
|
||||
return (core::fpclassify)(n) == core::fp_zero;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -264,7 +264,7 @@ namespace boost { namespace spirit { namespace traits
|
||||
{
|
||||
static bool call(float n)
|
||||
{
|
||||
return (math::fpclassify)(n) == FP_NAN;
|
||||
return (core::fpclassify)(n) == core::fp_nan;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -273,7 +273,7 @@ namespace boost { namespace spirit { namespace traits
|
||||
{
|
||||
static bool call(double n)
|
||||
{
|
||||
return (math::fpclassify)(n) == FP_NAN;
|
||||
return (core::fpclassify)(n) == core::fp_nan;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -282,7 +282,7 @@ namespace boost { namespace spirit { namespace traits
|
||||
{
|
||||
static bool call(long double n)
|
||||
{
|
||||
return (math::fpclassify)(n) == FP_NAN;
|
||||
return (core::fpclassify)(n) == core::fp_nan;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -298,9 +298,8 @@ namespace boost { namespace spirit { namespace traits
|
||||
{
|
||||
static bool call(T n)
|
||||
{
|
||||
if (!std::numeric_limits<T>::has_infinity)
|
||||
return false;
|
||||
return (n == std::numeric_limits<T>::infinity()) ? true : false;
|
||||
return std::numeric_limits<T>::has_infinity
|
||||
&& n == std::numeric_limits<T>::infinity();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -309,7 +308,7 @@ namespace boost { namespace spirit { namespace traits
|
||||
{
|
||||
static bool call(float n)
|
||||
{
|
||||
return (math::fpclassify)(n) == FP_INFINITE;
|
||||
return (core::fpclassify)(n) == core::fp_infinite;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -318,7 +317,7 @@ namespace boost { namespace spirit { namespace traits
|
||||
{
|
||||
static bool call(double n)
|
||||
{
|
||||
return (math::fpclassify)(n) == FP_INFINITE;
|
||||
return (core::fpclassify)(n) == core::fp_infinite;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -327,7 +326,7 @@ namespace boost { namespace spirit { namespace traits
|
||||
{
|
||||
static bool call(long double n)
|
||||
{
|
||||
return (math::fpclassify)(n) == FP_INFINITE;
|
||||
return (core::fpclassify)(n) == core::fp_infinite;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -575,12 +574,12 @@ namespace boost { namespace spirit { namespace karma
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
#define BOOST_KARMA_NUMERICS_INNER_LOOP_PREFIX(z, x, data) \
|
||||
if (!traits::test_zero(n)) { \
|
||||
int ch = radix_type::call(remainder_type::call(n)); \
|
||||
int ch_##x = radix_type::call(remainder_type::call(n)); \
|
||||
n = divide_type::call(n, num, ++exp); \
|
||||
/**/
|
||||
|
||||
#define BOOST_KARMA_NUMERICS_INNER_LOOP_SUFFIX(z, x, data) \
|
||||
*sink = char(ch); \
|
||||
#define BOOST_KARMA_NUMERICS_INNER_LOOP_SUFFIX(z, x, n_rolls_sub1) \
|
||||
*sink = char(BOOST_PP_CAT(ch_, BOOST_PP_SUB(n_rolls_sub1, x))); \
|
||||
++sink; \
|
||||
} \
|
||||
/**/
|
||||
@@ -611,7 +610,8 @@ namespace boost { namespace spirit { namespace karma
|
||||
|
||||
BOOST_PP_REPEAT(
|
||||
BOOST_KARMA_NUMERICS_LOOP_UNROLL,
|
||||
BOOST_KARMA_NUMERICS_INNER_LOOP_SUFFIX, _);
|
||||
BOOST_KARMA_NUMERICS_INNER_LOOP_SUFFIX,
|
||||
BOOST_PP_DEC(BOOST_KARMA_NUMERICS_LOOP_UNROLL));
|
||||
|
||||
*sink = char(ch);
|
||||
++sink;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2001-2011 Hartmut Kaiser
|
||||
// Copyright (c) 2001-2020 Hartmut Kaiser
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -18,7 +18,6 @@
|
||||
#include <boost/spirit/home/support/char_class.hpp>
|
||||
#include <boost/spirit/home/support/unused.hpp>
|
||||
#include <boost/spirit/home/support/detail/pow10.hpp>
|
||||
#include <boost/spirit/home/support/detail/sign.hpp>
|
||||
#include <boost/spirit/home/karma/detail/generate_to.hpp>
|
||||
#include <boost/spirit/home/karma/detail/string_generate.hpp>
|
||||
#include <boost/spirit/home/karma/numeric/detail/numeric_utils.hpp>
|
||||
@@ -84,34 +83,37 @@ namespace boost { namespace spirit { namespace karma
|
||||
|
||||
// get correct precision for generated number
|
||||
unsigned precision = p.precision(n);
|
||||
if (std::numeric_limits<U>::digits10)
|
||||
{
|
||||
// limit generated precision to digits10, if defined
|
||||
precision = (std::min)(precision,
|
||||
(unsigned)std::numeric_limits<U>::digits10 + 1);
|
||||
}
|
||||
|
||||
// allow for ADL to find the correct overloads for log10 et.al.
|
||||
using namespace std;
|
||||
|
||||
bool precexp_offset = false;
|
||||
U dim = 0;
|
||||
if (0 == (Policies::fmtflags::fixed & flags) && !traits::test_zero(n))
|
||||
{
|
||||
dim = log10(n);
|
||||
if (dim > 0)
|
||||
if (dim > 0)
|
||||
n /= spirit::traits::pow10<U>(traits::truncate_to_long::call(dim));
|
||||
else if (n < 1.) {
|
||||
long exp = traits::truncate_to_long::call(-dim);
|
||||
if (exp != -dim)
|
||||
++exp;
|
||||
|
||||
dim = static_cast<U>(-exp);
|
||||
|
||||
// detect and handle denormalized numbers to prevent overflow in pow10
|
||||
if (exp > std::numeric_limits<U>::max_exponent10)
|
||||
{
|
||||
n *= spirit::traits::pow10<U>(std::numeric_limits<U>::max_exponent10);
|
||||
n *= spirit::traits::pow10<U>(exp - std::numeric_limits<U>::max_exponent10);
|
||||
} else
|
||||
}
|
||||
else
|
||||
n *= spirit::traits::pow10<U>(exp);
|
||||
|
||||
if (n < 1.)
|
||||
{
|
||||
n *= 10.;
|
||||
--dim;
|
||||
precexp_offset = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,14 +122,28 @@ namespace boost { namespace spirit { namespace karma
|
||||
U precexp = spirit::traits::pow10<U>(precision);
|
||||
U fractional_part = modf(n, &integer_part);
|
||||
|
||||
fractional_part = floor(fractional_part * precexp + U(0.5));
|
||||
if (fractional_part >= precexp)
|
||||
if (precexp_offset)
|
||||
{
|
||||
fractional_part =
|
||||
floor((fractional_part * precexp + U(0.5)) * U(10.)) / U(10.);
|
||||
}
|
||||
else
|
||||
{
|
||||
fractional_part = floor(fractional_part * precexp + U(0.5));
|
||||
}
|
||||
|
||||
if (fractional_part >= precexp)
|
||||
{
|
||||
fractional_part = floor(fractional_part - precexp);
|
||||
integer_part += 1; // handle rounding overflow
|
||||
if (integer_part >= 10. && 0 == (Policies::fmtflags::fixed & flags))
|
||||
{
|
||||
integer_part /= 10.;
|
||||
++dim;
|
||||
}
|
||||
}
|
||||
|
||||
// if trailing zeros are to be omitted, normalize the precision and
|
||||
// if trailing zeros are to be omitted, normalize the precision and``
|
||||
// fractional part
|
||||
U long_int_part = floor(integer_part);
|
||||
U long_frac_part = fractional_part;
|
||||
|
||||
Reference in New Issue
Block a user