update boost
This commit is contained in:
@@ -5,8 +5,8 @@
|
||||
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)
|
||||
==============================================================================*/
|
||||
#if !defined(SPIRIT_QI_BOOL_SEP_29_2009_0709AM)
|
||||
#define SPIRIT_QI_BOOL_SEP_29_2009_0709AM
|
||||
#ifndef BOOST_SPIRIT_QI_NUMERIC_BOOL_HPP
|
||||
#define BOOST_SPIRIT_QI_NUMERIC_BOOL_HPP
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma once
|
||||
@@ -128,7 +128,7 @@ namespace boost { namespace spirit { namespace qi
|
||||
return false;
|
||||
|
||||
#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 (allow_true && p.parse_true(first, last, attr)) ||
|
||||
(!disallow_false && p.parse_false(first, last, attr));
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
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)
|
||||
==============================================================================*/
|
||||
#if !defined(SPIRIT_QI_BOOL_POLICIES_SEP_29_2009_0710AM)
|
||||
#define SPIRIT_QI_BOOL_POLICIES_SEP_29_2009_0710AM
|
||||
#ifndef BOOST_SPIRIT_QI_NUMERIC_BOOL_POLICIES_HPP
|
||||
#define BOOST_SPIRIT_QI_NUMERIC_BOOL_POLICIES_HPP
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma once
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
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)
|
||||
=============================================================================*/
|
||||
#if !defined(SPIRIT_NUMERIC_UTILS_APRIL_17_2006_0816AM)
|
||||
#define SPIRIT_NUMERIC_UTILS_APRIL_17_2006_0816AM
|
||||
#ifndef BOOST_SPIRIT_QI_NUMERIC_DETAIL_NUMERIC_UTILS_HPP
|
||||
#define BOOST_SPIRIT_QI_NUMERIC_DETAIL_NUMERIC_UTILS_HPP
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma once
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2011 Joel de Guzman
|
||||
Copyright (c) 2001-2019 Joel de Guzman
|
||||
Copyright (c) 2001-2011 Hartmut Kaiser
|
||||
http://spirit.sourceforge.net/
|
||||
|
||||
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)
|
||||
=============================================================================*/
|
||||
#if !defined(SPIRIT_REAL_IMPL_APRIL_18_2006_0901AM)
|
||||
#define SPIRIT_REAL_IMPL_APRIL_18_2006_0901AM
|
||||
#ifndef BOOST_SPIRIT_QI_NUMERIC_DETAIL_REAL_IMPL_HPP
|
||||
#define BOOST_SPIRIT_QI_NUMERIC_DETAIL_REAL_IMPL_HPP
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma once
|
||||
@@ -19,10 +19,11 @@
|
||||
#include <boost/spirit/home/support/unused.hpp>
|
||||
#include <boost/spirit/home/qi/detail/attributes.hpp>
|
||||
#include <boost/spirit/home/support/detail/pow10.hpp>
|
||||
#include <boost/spirit/home/support/detail/sign.hpp>
|
||||
#include <boost/integer.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
#include <boost/core/cmath.hpp>
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
|
||||
# pragma warning(push)
|
||||
# pragma warning(disable: 4100) // 'p': unreferenced formal parameter
|
||||
@@ -65,11 +66,11 @@ namespace boost { namespace spirit { namespace traits
|
||||
{
|
||||
if (exp >= 0)
|
||||
{
|
||||
int max_exp = std::numeric_limits<T>::max_exponent10;
|
||||
int const max_exp = std::numeric_limits<T>::max_exponent10;
|
||||
|
||||
// return false if exp exceeds the max_exp
|
||||
// do this check only for primitive types!
|
||||
if (is_floating_point<T>() && exp > max_exp)
|
||||
if (is_floating_point<T>() && (exp > max_exp))
|
||||
return false;
|
||||
n = acc_n * pow10<T>(exp);
|
||||
}
|
||||
@@ -77,7 +78,7 @@ namespace boost { namespace spirit { namespace traits
|
||||
{
|
||||
if (exp < std::numeric_limits<T>::min_exponent10)
|
||||
{
|
||||
int min_exp = std::numeric_limits<T>::min_exponent10;
|
||||
int const min_exp = std::numeric_limits<T>::min_exponent10;
|
||||
detail::compensate_roundoff(n, acc_n);
|
||||
n /= pow10<T>(-min_exp);
|
||||
|
||||
@@ -121,19 +122,19 @@ namespace boost { namespace spirit { namespace traits
|
||||
inline float
|
||||
negate(bool neg, float n)
|
||||
{
|
||||
return neg ? spirit::detail::changesign(n) : n;
|
||||
return neg ? (core::copysign)(n, -1.f) : n;
|
||||
}
|
||||
|
||||
inline double
|
||||
negate(bool neg, double n)
|
||||
{
|
||||
return neg ? spirit::detail::changesign(n) : n;
|
||||
return neg ? (core::copysign)(n, -1.) : n;
|
||||
}
|
||||
|
||||
inline long double
|
||||
negate(bool neg, long double n)
|
||||
{
|
||||
return neg ? spirit::detail::changesign(n) : n;
|
||||
return neg ? (core::copysign)(n, static_cast<long double>(-1)) : n;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
@@ -164,9 +165,33 @@ namespace boost { namespace spirit { namespace traits
|
||||
|
||||
namespace boost { namespace spirit { namespace qi { namespace detail
|
||||
{
|
||||
BOOST_MPL_HAS_XXX_TRAIT_DEF(version)
|
||||
|
||||
template <typename T, typename RealPolicies>
|
||||
struct real_impl
|
||||
{
|
||||
template <typename Iterator>
|
||||
static std::size_t
|
||||
ignore_excess_digits(Iterator& /* first */, Iterator const& /* last */, mpl::false_)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
template <typename Iterator>
|
||||
static std::size_t
|
||||
ignore_excess_digits(Iterator& first, Iterator const& last, mpl::true_)
|
||||
{
|
||||
return RealPolicies::ignore_excess_digits(first, last);
|
||||
}
|
||||
|
||||
template <typename Iterator>
|
||||
static std::size_t
|
||||
ignore_excess_digits(Iterator& first, Iterator const& last)
|
||||
{
|
||||
typedef mpl::bool_<has_version<RealPolicies>::value> has_version;
|
||||
return ignore_excess_digits(first, last, has_version());
|
||||
}
|
||||
|
||||
template <typename Iterator, typename Attribute>
|
||||
static bool
|
||||
parse(Iterator& first, Iterator const& last, Attribute& attr,
|
||||
@@ -185,6 +210,7 @@ namespace boost { namespace spirit { namespace qi { namespace detail
|
||||
|
||||
typename traits::real_accumulator<T>::type acc_n = 0;
|
||||
bool got_a_number = p.parse_n(first, last, acc_n);
|
||||
int excess_n = 0;
|
||||
|
||||
// If we did not get a number it might be a NaN, Inf or a leading
|
||||
// dot.
|
||||
@@ -207,6 +233,12 @@ namespace boost { namespace spirit { namespace qi { namespace detail
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// We got a number and we still see digits. This happens if acc_n (an integer)
|
||||
// exceeds the integer's capacity. Collect the excess digits.
|
||||
excess_n = static_cast<int>(ignore_excess_digits(first, last));
|
||||
}
|
||||
|
||||
bool e_hit = false;
|
||||
Iterator e_pos;
|
||||
@@ -218,7 +250,12 @@ namespace boost { namespace spirit { namespace qi { namespace detail
|
||||
// We got the decimal point. Now we will try to parse
|
||||
// the fraction if it is there. If not, it defaults
|
||||
// to zero (0) only if we already got a number.
|
||||
if (p.parse_frac_n(first, last, acc_n, frac_digits))
|
||||
if (excess_n != 0)
|
||||
{
|
||||
// We skip the fractions if we already exceeded our digits capacity
|
||||
ignore_excess_digits(first, last);
|
||||
}
|
||||
else if (p.parse_frac_n(first, last, acc_n, frac_digits))
|
||||
{
|
||||
BOOST_ASSERT(frac_digits >= 0);
|
||||
}
|
||||
@@ -263,8 +300,8 @@ namespace boost { namespace spirit { namespace qi { namespace detail
|
||||
if (p.parse_exp_n(first, last, exp))
|
||||
{
|
||||
// Got the exponent value. Scale the number by
|
||||
// exp-frac_digits.
|
||||
if (!traits::scale(exp, frac_digits, n, acc_n))
|
||||
// exp + excess_n - frac_digits.
|
||||
if (!traits::scale(exp + excess_n, frac_digits, n, acc_n))
|
||||
return false;
|
||||
}
|
||||
else
|
||||
@@ -285,7 +322,15 @@ namespace boost { namespace spirit { namespace qi { namespace detail
|
||||
}
|
||||
else
|
||||
{
|
||||
n = static_cast<T>(acc_n);
|
||||
if (excess_n)
|
||||
{
|
||||
if (!traits::scale(excess_n, n, acc_n))
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
n = static_cast<T>(acc_n);
|
||||
}
|
||||
}
|
||||
|
||||
// If we got a negative sign, negate the number
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2011 Joel de Guzman
|
||||
Copyright (c) 2001-2019 Joel de Guzman
|
||||
Copyright (c) 2001-2011 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)
|
||||
==============================================================================*/
|
||||
#if !defined(SPIRIT_REAL_POLICIES_APRIL_17_2006_1158PM)
|
||||
#define SPIRIT_REAL_POLICIES_APRIL_17_2006_1158PM
|
||||
#ifndef BOOST_SPIRIT_QI_NUMERIC_REAL_POLICIES_HPP
|
||||
#define BOOST_SPIRIT_QI_NUMERIC_REAL_POLICIES_HPP
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma once
|
||||
@@ -14,6 +14,29 @@
|
||||
|
||||
#include <boost/spirit/home/qi/numeric/numeric_utils.hpp>
|
||||
#include <boost/spirit/home/qi/detail/string_parse.hpp>
|
||||
#include <boost/type_traits/is_floating_point.hpp>
|
||||
|
||||
namespace boost { namespace spirit { namespace traits
|
||||
{
|
||||
// So that we won't exceed the capacity of the underlying type T,
|
||||
// we limit the number of digits parsed to its max_digits10.
|
||||
// By default, the value is -1 which tells spirit to parse an
|
||||
// unbounded number of digits.
|
||||
|
||||
template <typename T, typename Enable = void>
|
||||
struct max_digits10
|
||||
{
|
||||
static int const value = -1; // unbounded
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct max_digits10<T
|
||||
, typename enable_if_c<(is_floating_point<T>::value)>::type>
|
||||
{
|
||||
static int const digits = std::numeric_limits<T>::digits;
|
||||
static int const value = 2 + (digits * 30103l) / 100000l;
|
||||
};
|
||||
}}}
|
||||
|
||||
namespace boost { namespace spirit { namespace qi
|
||||
{
|
||||
@@ -23,6 +46,9 @@ namespace boost { namespace spirit { namespace qi
|
||||
template <typename T>
|
||||
struct ureal_policies
|
||||
{
|
||||
// Versioning
|
||||
typedef mpl::int_<2> version;
|
||||
|
||||
// trailing dot policy suggested by Gustavo Guerra
|
||||
static bool const allow_leading_dot = true;
|
||||
static bool const allow_trailing_dot = true;
|
||||
@@ -39,7 +65,22 @@ namespace boost { namespace spirit { namespace qi
|
||||
static bool
|
||||
parse_n(Iterator& first, Iterator const& last, Attribute& attr_)
|
||||
{
|
||||
return extract_uint<Attribute, 10, 1, -1>::call(first, last, attr_);
|
||||
typedef extract_uint<Attribute, 10, 1
|
||||
, traits::max_digits10<T>::value // See notes on max_digits10 above
|
||||
, false, true>
|
||||
extract_uint;
|
||||
return extract_uint::call(first, last, attr_);
|
||||
}
|
||||
|
||||
// ignore_excess_digits (required for version > 1 API)
|
||||
template <typename Iterator>
|
||||
static std::size_t
|
||||
ignore_excess_digits(Iterator& first, Iterator const& last)
|
||||
{
|
||||
Iterator save = first;
|
||||
if (extract_uint<unused_type, 10, 1, -1>::call(first, last, unused))
|
||||
return static_cast<std::size_t>(std::distance(save, first));
|
||||
return 0;
|
||||
}
|
||||
|
||||
template <typename Iterator>
|
||||
@@ -60,11 +101,18 @@ namespace boost { namespace spirit { namespace qi
|
||||
bool r = extract_uint<Attribute, 10, 1, -1, true, true>::call(first, last, attr_);
|
||||
if (r)
|
||||
{
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1900
|
||||
# pragma warning(push)
|
||||
# pragma warning(disable: 4127) // conditional expression is constant
|
||||
#endif
|
||||
// Optimization note: don't compute frac_digits if T is
|
||||
// an unused_type. This should be optimized away by the compiler.
|
||||
if (!is_same<T, unused_type>::value)
|
||||
frac_digits =
|
||||
static_cast<int>(std::distance(savef, first));
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1900
|
||||
# pragma warning(pop)
|
||||
#endif
|
||||
// ignore extra (non-significant digits)
|
||||
extract_uint<unused_type, 10, 1, -1>::call(first, last, unused);
|
||||
}
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
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)
|
||||
==============================================================================*/
|
||||
#if !defined(SPIRIT_UINT_APR_17_2006_0901AM)
|
||||
#define SPIRIT_UINT_APR_17_2006_0901AM
|
||||
#ifndef BOOST_SPIRIT_QI_NUMERIC_UINT_HPP
|
||||
#define BOOST_SPIRIT_QI_NUMERIC_UINT_HPP
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma once
|
||||
|
||||
Reference in New Issue
Block a user