updated boost on windows
This commit is contained in:
@@ -15,7 +15,6 @@
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/detail/iterator.hpp>
|
||||
#include <boost/spirit/home/support/unused.hpp>
|
||||
#include <boost/spirit/home/qi/detail/attributes.hpp>
|
||||
#include <boost/spirit/home/support/char_encoding/ascii.hpp>
|
||||
@@ -31,7 +30,8 @@
|
||||
#include <boost/mpl/bool.hpp>
|
||||
#include <boost/mpl/and.hpp>
|
||||
#include <boost/limits.hpp>
|
||||
#include <boost/integer_traits.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <iterator> // for std::iterator_traits
|
||||
|
||||
#if defined(BOOST_MSVC)
|
||||
# pragma warning(push)
|
||||
@@ -56,6 +56,9 @@ namespace boost { namespace spirit { namespace qi { namespace detail
|
||||
template <typename T, unsigned Radix>
|
||||
struct digits_traits;
|
||||
|
||||
template <int Digits, unsigned Radix>
|
||||
struct digits2_to_n;
|
||||
|
||||
// lookup table for log2(x) : 2 <= x <= 36
|
||||
#define BOOST_SPIRIT_LOG2 (#error)(#error) \
|
||||
(1000000)(1584960)(2000000)(2321920)(2584960)(2807350) \
|
||||
@@ -67,11 +70,10 @@ namespace boost { namespace spirit { namespace qi { namespace detail
|
||||
/***/
|
||||
|
||||
#define BOOST_PP_LOCAL_MACRO(Radix) \
|
||||
template <typename T> struct digits_traits<T, Radix> \
|
||||
template <int Digits> struct digits2_to_n<Digits, Radix> \
|
||||
{ \
|
||||
typedef std::numeric_limits<T> numeric_limits_type; \
|
||||
BOOST_STATIC_CONSTANT(int, value = static_cast<int>( \
|
||||
(numeric_limits_type::digits * 1000000) / \
|
||||
(Digits * 1000000) / \
|
||||
BOOST_PP_SEQ_ELEM(Radix, BOOST_SPIRIT_LOG2))); \
|
||||
}; \
|
||||
/***/
|
||||
@@ -81,6 +83,18 @@ namespace boost { namespace spirit { namespace qi { namespace detail
|
||||
|
||||
#undef BOOST_SPIRIT_LOG2
|
||||
|
||||
template <typename T, unsigned Radix>
|
||||
struct digits_traits : digits2_to_n<std::numeric_limits<T>::digits, Radix>
|
||||
{
|
||||
BOOST_STATIC_ASSERT(std::numeric_limits<T>::radix == 2);
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct digits_traits<T, 10>
|
||||
{
|
||||
static int const value = std::numeric_limits<T>::digits10;
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Traits class for radix specific number conversion
|
||||
@@ -101,11 +115,9 @@ namespace boost { namespace spirit { namespace qi { namespace detail
|
||||
template <typename Char>
|
||||
inline static bool is_valid(Char ch)
|
||||
{
|
||||
if (Radix <= 10)
|
||||
return (ch >= '0' && ch <= static_cast<Char>('0' + Radix -1));
|
||||
return (ch >= '0' && ch <= '9')
|
||||
|| (ch >= 'a' && ch <= static_cast<Char>('a' + Radix -10 -1))
|
||||
|| (ch >= 'A' && ch <= static_cast<Char>('A' + Radix -10 -1));
|
||||
return (ch >= '0' && ch <= (Radix > 10 ? '9' : static_cast<Char>('0' + Radix -1)))
|
||||
|| (Radix > 10 && ch >= 'a' && ch <= static_cast<Char>('a' + Radix -10 -1))
|
||||
|| (Radix > 10 && ch >= 'A' && ch <= static_cast<Char>('A' + Radix -10 -1));
|
||||
}
|
||||
|
||||
template <typename Char>
|
||||
@@ -116,12 +128,6 @@ namespace boost { namespace spirit { namespace qi { namespace detail
|
||||
return spirit::char_encoding::ascii::tolower(ch) - 'a' + 10;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T, T Val>
|
||||
struct constexpr_int
|
||||
{
|
||||
BOOST_STATIC_CONSTEXPR T value = Val;
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// positive_accumulator/negative_accumulator: Accumulator policies for
|
||||
@@ -142,20 +148,20 @@ namespace boost { namespace spirit { namespace qi { namespace detail
|
||||
inline static bool add(T& n, Char ch, mpl::true_) // checked add
|
||||
{
|
||||
// Ensure n *= Radix will not overflow
|
||||
typedef constexpr_int<T, boost::integer_traits<T>::const_max> max;
|
||||
typedef constexpr_int<T, max::value / Radix> val;
|
||||
T const max = (std::numeric_limits<T>::max)();
|
||||
T const val = max / Radix;
|
||||
|
||||
if (n > val::value)
|
||||
if (n > val)
|
||||
return false;
|
||||
|
||||
n *= Radix;
|
||||
T tmp = n * Radix;
|
||||
|
||||
// Ensure n += digit will not overflow
|
||||
const int digit = radix_traits<Radix>::digit(ch);
|
||||
if (n > max::value - digit)
|
||||
if (tmp > max - digit)
|
||||
return false;
|
||||
|
||||
n += static_cast<T>(digit);
|
||||
n = tmp + static_cast<T>(digit);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
@@ -174,20 +180,20 @@ namespace boost { namespace spirit { namespace qi { namespace detail
|
||||
inline static bool add(T& n, Char ch, mpl::true_) // checked subtract
|
||||
{
|
||||
// Ensure n *= Radix will not underflow
|
||||
typedef constexpr_int<T, boost::integer_traits<T>::const_min> min;
|
||||
typedef constexpr_int<T, (min::value + 1) / T(Radix)> val;
|
||||
T const min = (std::numeric_limits<T>::min)();
|
||||
T const val = min / T(Radix);
|
||||
|
||||
if (n < val::value)
|
||||
if (n < val)
|
||||
return false;
|
||||
|
||||
n *= Radix;
|
||||
T tmp = n * Radix;
|
||||
|
||||
// Ensure n -= digit will not underflow
|
||||
int const digit = radix_traits<Radix>::digit(ch);
|
||||
if (n < min::value + digit)
|
||||
if (tmp < min + digit)
|
||||
return false;
|
||||
|
||||
n -= static_cast<T>(digit);
|
||||
n = tmp - static_cast<T>(digit);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
@@ -202,9 +208,9 @@ namespace boost { namespace spirit { namespace qi { namespace detail
|
||||
inline static bool
|
||||
call(Char ch, std::size_t count, T& n, mpl::true_)
|
||||
{
|
||||
typedef constexpr_int<std::size_t, digits_traits<T, Radix>::value - 1> overflow_free;
|
||||
std::size_t const overflow_free = digits_traits<T, Radix>::value - 1;
|
||||
|
||||
if (!AlwaysCheckOverflow && (count < overflow_free::value))
|
||||
if (!AlwaysCheckOverflow && (count < overflow_free))
|
||||
{
|
||||
Accumulator::add(n, ch, mpl::false_());
|
||||
}
|
||||
@@ -278,14 +284,20 @@ namespace boost { namespace spirit { namespace qi { namespace detail
|
||||
#define SPIRIT_NUMERIC_INNER_LOOP(z, x, data) \
|
||||
if (!check_max_digits<MaxDigits>::call(count + leading_zeros) \
|
||||
|| it == last) \
|
||||
{ \
|
||||
break; \
|
||||
} \
|
||||
ch = *it; \
|
||||
if (!radix_check::is_valid(ch)) \
|
||||
{ \
|
||||
break; \
|
||||
} \
|
||||
if (!extractor::call(ch, count, val)) \
|
||||
{ \
|
||||
if (IgnoreOverflowDigits) \
|
||||
{ \
|
||||
first = it; \
|
||||
} \
|
||||
traits::assign_to(val, attr); \
|
||||
return IgnoreOverflowDigits; \
|
||||
} \
|
||||
@@ -314,9 +326,7 @@ namespace boost { namespace spirit { namespace qi { namespace detail
|
||||
{
|
||||
typedef radix_traits<Radix> radix_check;
|
||||
typedef int_extractor<Radix, Accumulator, MaxDigits, Accumulate> extractor;
|
||||
typedef typename
|
||||
boost::detail::iterator_traits<Iterator>::value_type
|
||||
char_type;
|
||||
typedef typename std::iterator_traits<Iterator>::value_type char_type;
|
||||
|
||||
Iterator it = first;
|
||||
std::size_t leading_zeros = 0;
|
||||
@@ -386,10 +396,14 @@ namespace boost { namespace spirit { namespace qi { namespace detail
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
#define SPIRIT_NUMERIC_INNER_LOOP(z, x, data) \
|
||||
if (it == last) \
|
||||
{ \
|
||||
break; \
|
||||
} \
|
||||
ch = *it; \
|
||||
if (!radix_check::is_valid(ch)) \
|
||||
{ \
|
||||
break; \
|
||||
} \
|
||||
if (!extractor::call(ch, count, val)) \
|
||||
{ \
|
||||
traits::assign_to(val, attr); \
|
||||
@@ -415,9 +429,7 @@ namespace boost { namespace spirit { namespace qi { namespace detail
|
||||
{
|
||||
typedef radix_traits<Radix> radix_check;
|
||||
typedef int_extractor<Radix, Accumulator, -1, Accumulate> extractor;
|
||||
typedef typename
|
||||
boost::detail::iterator_traits<Iterator>::value_type
|
||||
char_type;
|
||||
typedef typename std::iterator_traits<Iterator>::value_type char_type;
|
||||
|
||||
Iterator it = first;
|
||||
std::size_t count = 0;
|
||||
@@ -496,35 +508,6 @@ namespace boost { namespace spirit { namespace qi { namespace detail
|
||||
};
|
||||
|
||||
#undef SPIRIT_NUMERIC_INNER_LOOP
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Cast an signed integer to an unsigned integer
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
template <typename T,
|
||||
bool force_unsigned
|
||||
= mpl::and_<is_integral<T>, is_signed<T> >::value>
|
||||
struct cast_unsigned;
|
||||
|
||||
template <typename T>
|
||||
struct cast_unsigned<T, true>
|
||||
{
|
||||
typedef typename make_unsigned<T>::type unsigned_type;
|
||||
typedef typename make_unsigned<T>::type& unsigned_type_ref;
|
||||
|
||||
inline static unsigned_type_ref call(T& n)
|
||||
{
|
||||
return unsigned_type_ref(n);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct cast_unsigned<T, false>
|
||||
{
|
||||
inline static T& call(T& n)
|
||||
{
|
||||
return n;
|
||||
}
|
||||
};
|
||||
}}}}
|
||||
|
||||
#if defined(BOOST_MSVC)
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
namespace boost { namespace spirit { namespace traits
|
||||
{
|
||||
using spirit::traits::pow10;
|
||||
|
||||
|
||||
namespace detail
|
||||
{
|
||||
template <typename T, typename AccT>
|
||||
@@ -44,14 +44,14 @@ namespace boost { namespace spirit { namespace traits
|
||||
n = T((acc_n / comp) * comp);
|
||||
n += T(acc_n % comp);
|
||||
}
|
||||
|
||||
|
||||
template <typename T, typename AccT>
|
||||
void compensate_roundoff(T& n, AccT acc_n, mpl::false_)
|
||||
{
|
||||
// no need to compensate
|
||||
n = acc_n;
|
||||
}
|
||||
|
||||
|
||||
template <typename T, typename AccT>
|
||||
void compensate_roundoff(T& n, AccT acc_n)
|
||||
{
|
||||
@@ -66,7 +66,7 @@ namespace boost { namespace spirit { namespace traits
|
||||
if (exp >= 0)
|
||||
{
|
||||
int 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)
|
||||
@@ -80,13 +80,14 @@ namespace boost { namespace spirit { namespace traits
|
||||
int min_exp = std::numeric_limits<T>::min_exponent10;
|
||||
detail::compensate_roundoff(n, acc_n);
|
||||
n /= pow10<T>(-min_exp);
|
||||
|
||||
// return false if (-exp + min_exp) exceeds the -min_exp
|
||||
|
||||
// return false if exp still exceeds the min_exp
|
||||
// do this check only for primitive types!
|
||||
if (is_floating_point<T>() && (-exp + min_exp) > -min_exp)
|
||||
exp += -min_exp;
|
||||
if (is_floating_point<T>() && exp < min_exp)
|
||||
return false;
|
||||
|
||||
n /= pow10<T>(-exp + min_exp);
|
||||
n /= pow10<T>(-exp);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -149,20 +150,6 @@ namespace boost { namespace spirit { namespace traits
|
||||
return n;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline bool
|
||||
is_equal_to_one(T const& value)
|
||||
{
|
||||
return value == 1.0;
|
||||
}
|
||||
|
||||
inline bool
|
||||
is_equal_to_one(unused_type)
|
||||
{
|
||||
// no-op for unused_type
|
||||
return false;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
struct real_accumulator : mpl::identity<T> {};
|
||||
|
||||
@@ -233,6 +220,7 @@ namespace boost { namespace spirit { namespace qi { namespace detail
|
||||
// to zero (0) only if we already got a number.
|
||||
if (p.parse_frac_n(first, last, acc_n, frac_digits))
|
||||
{
|
||||
BOOST_ASSERT(frac_digits >= 0);
|
||||
}
|
||||
else if (!got_a_number || !p.allow_trailing_dot)
|
||||
{
|
||||
@@ -284,29 +272,16 @@ namespace boost { namespace spirit { namespace qi { namespace detail
|
||||
// If there is no number, disregard the exponent altogether.
|
||||
// by resetting 'first' prior to the exponent prefix (e|E)
|
||||
first = e_pos;
|
||||
n = static_cast<T>(acc_n);
|
||||
// Scale the number by -frac_digits.
|
||||
bool r = traits::scale(-frac_digits, n, acc_n);
|
||||
BOOST_VERIFY(r);
|
||||
}
|
||||
}
|
||||
else if (frac_digits)
|
||||
{
|
||||
// No exponent found. Scale the number by -frac_digits.
|
||||
traits::scale(-frac_digits, n, acc_n);
|
||||
}
|
||||
else if (traits::is_equal_to_one(acc_n))
|
||||
{
|
||||
// There is a chance of having to parse one of the 1.0#...
|
||||
// styles some implementations use for representing NaN or Inf.
|
||||
|
||||
// Check whether the number to parse is a NaN or Inf
|
||||
if (p.parse_nan(first, last, n) ||
|
||||
p.parse_inf(first, last, n))
|
||||
{
|
||||
// If we got a negative sign, negate the number
|
||||
traits::assign_to(traits::negate(neg, n), attr);
|
||||
return true; // got a NaN or Inf, return immediately
|
||||
}
|
||||
|
||||
n = static_cast<T>(acc_n);
|
||||
bool r = traits::scale(-frac_digits, n, acc_n);
|
||||
BOOST_VERIFY(r);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user