Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r56026 - in trunk/boost/spirit/home/qi/numeric: . detail
From: joel_at_[hidden]
Date: 2009-09-05 02:29:30


Author: djowel
Date: 2009-09-05 02:29:29 EDT (Sat, 05 Sep 2009)
New Revision: 56026
URL: http://svn.boost.org/trac/boost/changeset/56026

Log:
Minor tweaks
Text files modified:
   trunk/boost/spirit/home/qi/numeric/detail/numeric_utils.hpp | 9 +
   trunk/boost/spirit/home/qi/numeric/detail/real_impl.hpp | 164 ++++++++++++++++++++--------------------
   trunk/boost/spirit/home/qi/numeric/real.hpp | 2
   3 files changed, 88 insertions(+), 87 deletions(-)

Modified: trunk/boost/spirit/home/qi/numeric/detail/numeric_utils.hpp
==============================================================================
--- trunk/boost/spirit/home/qi/numeric/detail/numeric_utils.hpp (original)
+++ trunk/boost/spirit/home/qi/numeric/detail/numeric_utils.hpp 2009-09-05 02:29:29 EDT (Sat, 05 Sep 2009)
@@ -163,7 +163,7 @@
         static void add(T& n, Char ch, mpl::false_) // unchecked add
         {
             const int digit = radix_traits<Radix>::digit(ch);
- n = n * Radix + digit;
+ n = n * T(int(Radix + digit));
         }
 
         template <typename T, typename Char>
@@ -194,7 +194,7 @@
         static void add(T& n, Char ch, mpl::false_) // unchecked subtract
         {
             const int digit = radix_traits<Radix>::digit(ch);
- n = n * Radix - digit;
+ n = n * T(int(Radix - digit));
         }
 
         template <typename T, typename Char>
@@ -269,6 +269,7 @@
                     || (MaxDigits > radix_traits<Radix>::template digits<T>::value)
                     )
                   && std::numeric_limits<T>::is_modulo
+ && !std::numeric_limits<T>::is_bounded
>()
             );
         }
@@ -349,7 +350,7 @@
                 }
             }
 
- Attribute val = Accumulate ? attr : 0;
+ Attribute val = Accumulate ? attr : Attribute(0);
             std::size_t count = 0;
             char_type ch;
 
@@ -450,7 +451,7 @@
                 }
             }
 
- Attribute val = Accumulate ? attr : 0;
+ Attribute val = Accumulate ? attr : Attribute(0);
             char_type ch = *it;
 
             if (!radix_check::is_valid(ch) || !extractor::call(ch, 0, val))

Modified: trunk/boost/spirit/home/qi/numeric/detail/real_impl.hpp
==============================================================================
--- trunk/boost/spirit/home/qi/numeric/detail/real_impl.hpp (original)
+++ trunk/boost/spirit/home/qi/numeric/detail/real_impl.hpp 2009-09-05 02:29:29 EDT (Sat, 05 Sep 2009)
@@ -27,103 +27,103 @@
 # pragma warning(disable: 4127) // conditional expression is constant
 #endif
 
-namespace boost { namespace spirit { namespace qi { namespace detail
+namespace boost { namespace spirit { namespace traits
 {
- namespace
- {
- using spirit::detail::pow10;
+ using spirit::detail::pow10;
 
- template <typename T>
- inline void
- scale_number(int exp, T& n)
+ template <typename T>
+ inline void
+ scale(int exp, T& n)
+ {
+ if (exp >= 0)
         {
- if (exp >= 0)
+ // $$$ Why is this failing for boost.math.concepts ? $$$
+ //~ int nn = std::numeric_limits<T>::max_exponent10;
+ //~ BOOST_ASSERT(exp <= std::numeric_limits<T>::max_exponent10);
+ n *= pow10<T>(exp);
+ }
+ else
+ {
+ if (exp < std::numeric_limits<T>::min_exponent10)
             {
- // $$$ Why is this failing for boost.math.concepts ? $$$
- //~ int nn = std::numeric_limits<T>::max_exponent10;
- //~ BOOST_ASSERT(exp <= std::numeric_limits<T>::max_exponent10);
- n *= pow10<T>(exp);
+ n /= pow10<T>(-std::numeric_limits<T>::min_exponent10);
+ n /= pow10<T>(-exp + std::numeric_limits<T>::min_exponent10);
             }
             else
             {
- if (exp < std::numeric_limits<T>::min_exponent10)
- {
- n /= pow10<T>(-std::numeric_limits<T>::min_exponent10);
- n /= pow10<T>(-exp + std::numeric_limits<T>::min_exponent10);
- }
- else
- {
- n /= pow10<T>(-exp);
- }
+ n /= pow10<T>(-exp);
             }
         }
+ }
 
- inline void
- scale_number(int /*exp*/, unused_type /*n*/)
- {
- // no-op for unused_type
- }
+ inline void
+ scale(int /*exp*/, unused_type /*n*/)
+ {
+ // no-op for unused_type
+ }
 
- template <typename T>
- inline void
- scale_number(int exp, int frac, T& n)
- {
- scale_number(exp - frac, n);
- }
+ template <typename T>
+ inline void
+ scale(int exp, int frac, T& n)
+ {
+ scale(exp - frac, n);
+ }
 
- inline void
- scale_number(int /*exp*/, int /*frac*/, unused_type /*n*/)
- {
- // no-op for unused_type
- }
+ inline void
+ scale(int /*exp*/, int /*frac*/, unused_type /*n*/)
+ {
+ // no-op for unused_type
+ }
 
- inline float
- negate_number(bool neg, float n)
- {
- return neg ? spirit::detail::changesign(n) : n;
- }
+ inline float
+ negate(bool neg, float n)
+ {
+ return neg ? spirit::detail::changesign(n) : n;
+ }
 
- inline double
- negate_number(bool neg, double n)
- {
- return neg ? spirit::detail::changesign(n) : n;
- }
+ inline double
+ negate(bool neg, double n)
+ {
+ return neg ? spirit::detail::changesign(n) : n;
+ }
 
- inline long double
- negate_number(bool neg, long double n)
- {
- return neg ? spirit::detail::changesign(n) : n;
- }
+ inline long double
+ negate(bool neg, long double n)
+ {
+ return neg ? spirit::detail::changesign(n) : n;
+ }
 
- template <typename T>
- inline T
- negate_number(bool neg, T const& n)
- {
- return neg ? -n : n;
- }
+ template <typename T>
+ inline T
+ negate(bool neg, T const& n)
+ {
+ return neg ? -n : n;
+ }
 
- inline unused_type
- negate_number(bool /*neg*/, unused_type n)
- {
- // no-op for unused_type
- return n;
- }
+ inline unused_type
+ negate(bool /*neg*/, unused_type n)
+ {
+ // no-op for unused_type
+ return n;
+ }
 
- template <typename T>
- inline bool
- number_equal_to_one(T const& value)
- {
- return value == 1.0;
- }
+ template <typename T>
+ inline bool
+ is_equal_to_one(T const& value)
+ {
+ return value == 1.0;
+ }
 
- inline bool
- number_equal_to_one(unused_type)
- {
- // no-op for unused_type
- return false;
- }
+ inline bool
+ is_equal_to_one(unused_type)
+ {
+ // no-op for unused_type
+ return false;
     }
+}}}
 
+namespace boost { namespace spirit { namespace qi { namespace detail
+{
     template <typename T, typename RealPolicies>
     struct real_impl
     {
@@ -153,7 +153,7 @@
                     p.parse_inf(first, last, attr))
                 {
                     // If we got a negative sign, negate the number
- attr = negate_number(neg, attr);
+ attr = traits::negate(neg, attr);
                     return true; // got a NaN or Inf, return early
                 }
 
@@ -224,7 +224,7 @@
                 {
                     // Got the exponent value. Scale the number by
                     // exp-frac_digits.
- scale_number(exp, frac_digits, n);
+ traits::scale(exp, frac_digits, n);
                 }
                 else
                 {
@@ -236,9 +236,9 @@
             else if (frac_digits)
             {
                 // No exponent found. Scale the number by -frac_digits.
- scale_number(-frac_digits, n);
+ traits::scale(-frac_digits, n);
             }
- else if (number_equal_to_one(n))
+ else if (traits::is_equal_to_one(n))
             {
                 // There is a chance of having to parse one of the 1.0#...
                 // styles some implementations use for representing NaN or Inf.
@@ -248,13 +248,13 @@
                     p.parse_inf(first, last, attr))
                 {
                     // If we got a negative sign, negate the number
- attr = negate_number(neg, attr);
+ attr = traits::negate(neg, attr);
                     return true; // got a NaN or Inf, return immediately
                 }
             }
 
             // If we got a negative sign, negate the number
- attr = negate_number(neg, n);
+ attr = traits::negate(neg, n);
 
             // Success!!!
             return true;

Modified: trunk/boost/spirit/home/qi/numeric/real.hpp
==============================================================================
--- trunk/boost/spirit/home/qi/numeric/real.hpp (original)
+++ trunk/boost/spirit/home/qi/numeric/real.hpp 2009-09-05 02:29:29 EDT (Sat, 05 Sep 2009)
@@ -84,7 +84,7 @@
     // This one is the class that the user can instantiate directly
     ///////////////////////////////////////////////////////////////////////////
     template <
- typename T = double,
+ typename T,
         typename RealPolicies = real_policies<T>
>
     struct real_parser


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk