|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r85440 - in trunk/boost/spirit/home: qi/numeric/detail support
From: joel_at_[hidden]
Date: 2013-08-23 22:32:49
Author: djowel
Date: 2013-08-23 22:32:49 EDT (Fri, 23 Aug 2013)
New Revision: 85440
URL: http://svn.boost.org/trac/boost/changeset/85440
Log:
Simplified code for overflow handling: looking at the code i see now that it is actually safer to always check for overflow by default. most architectures have 2s complement anyway, so the optimization only happens on some obscure architecture where ints do not wrap (also for floats--they do not wrap as well). i'll simply have ints check for overflow *always* and provide a CP for special types that the user can specialize for optimization.
Text files modified:
trunk/boost/spirit/home/qi/numeric/detail/numeric_utils.hpp | 2 +-
trunk/boost/spirit/home/support/numeric_traits.hpp | 14 +++++---------
2 files changed, 6 insertions(+), 10 deletions(-)
Modified: trunk/boost/spirit/home/qi/numeric/detail/numeric_utils.hpp
==============================================================================
--- trunk/boost/spirit/home/qi/numeric/detail/numeric_utils.hpp Fri Aug 23 14:35:46 2013 (r85439)
+++ trunk/boost/spirit/home/qi/numeric/detail/numeric_utils.hpp 2013-08-23 22:32:49 EDT (Fri, 23 Aug 2013) (r85440)
@@ -228,7 +228,7 @@
( (MaxDigits < 0)
|| (MaxDigits > digits_traits<T, Radix>::value)
)
- && traits::is_integer_wrapping<T>::value
+ && traits::check_overflow<T>::value
>()
);
}
Modified: trunk/boost/spirit/home/support/numeric_traits.hpp
==============================================================================
--- trunk/boost/spirit/home/support/numeric_traits.hpp Fri Aug 23 14:35:46 2013 (r85439)
+++ trunk/boost/spirit/home/support/numeric_traits.hpp 2013-08-23 22:32:49 EDT (Fri, 23 Aug 2013) (r85440)
@@ -115,17 +115,13 @@
template <typename T, typename Enable = void>
struct is_infinite;
-
+
template <typename T, typename Enable = void>
- struct is_integer_wrapping : mpl::false_ {};
-
- template <typename T>
- struct is_integer_wrapping_default
- : mpl::bool_<(static_cast<T>(integer_traits<T>::const_max + 1) == integer_traits<T>::const_min)> {};
-
+ struct check_overflow : mpl::false_ {};
+
template <typename T>
- struct is_integer_wrapping<T, typename enable_if_c<integer_traits<T>::is_integral>::type>
- : is_integer_wrapping_default<T> {};
+ struct check_overflow<T, typename enable_if_c<integer_traits<T>::is_integral>::type>
+ : mpl::true_ {};
}}}
#endif
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