|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r61953 - in sandbox/SOC/2010/bit_masks/boost/integer: . details
From: bbartmanboost_at_[hidden]
Date: 2010-05-13 12:23:19
Author: bbartman
Date: 2010-05-13 12:23:18 EDT (Thu, 13 May 2010)
New Revision: 61953
URL: http://svn.boost.org/trac/boost/changeset/61953
Log:
working on precondtions for masks
Text files modified:
sandbox/SOC/2010/bit_masks/boost/integer/bit_mask.hpp | 4 +++-
sandbox/SOC/2010/bit_masks/boost/integer/details/bit_mask_impl.hpp | 33 ++++++++++++++++++++++++---------
2 files changed, 27 insertions(+), 10 deletions(-)
Modified: sandbox/SOC/2010/bit_masks/boost/integer/bit_mask.hpp
==============================================================================
--- sandbox/SOC/2010/bit_masks/boost/integer/bit_mask.hpp (original)
+++ sandbox/SOC/2010/bit_masks/boost/integer/bit_mask.hpp 2010-05-13 12:23:18 EDT (Thu, 13 May 2010)
@@ -34,8 +34,10 @@
*/
template <typename T, T Value>
struct integral_mask
+ :details::integral_mask_preconditions<T,Value>,
+ integral_constant<T, Value>
{
-
+ typedef integral_mask<T,Value> type;
};
} // namespace boost
Modified: sandbox/SOC/2010/bit_masks/boost/integer/details/bit_mask_impl.hpp
==============================================================================
--- sandbox/SOC/2010/bit_masks/boost/integer/details/bit_mask_impl.hpp (original)
+++ sandbox/SOC/2010/bit_masks/boost/integer/details/bit_mask_impl.hpp 2010-05-13 12:23:18 EDT (Thu, 13 May 2010)
@@ -11,6 +11,7 @@
#include <boost/mpl/bitwise.hpp>
#include <boost/static_assert.hpp>
#include <boost/integer/bit_width.hpp>
+#include <limits>
namespace boost { namespace details {
@@ -22,11 +23,9 @@
* 1. The width of the masked section must not be longer then the
* mask itself.
*
- * 2. Valid range for offset is >= 0.
- *
- * 3. Valid range for mask width is > 0.
+ * 2. Valid range for mask width is > 0.
*
- * 4. The type which is being masked must satisfy the is_integral type trait.
+ * 3. The type which is being masked must satisfy the is_integral type trait.
*/
template <typename T, unsigned int Offset, unsigned int Width>
struct bit_mask_preconditions {
@@ -35,16 +34,32 @@
BOOST_STATIC_ASSERT(( (Offset + Width) < ( bit_width<T>::value - 1) ));
// precondition 2.
- // this is always true because the offset is specified as an unsigned integer.
- // BOOST_STATIC_ASSERT(( >= 0 ));
-
- // precondition 3.
BOOST_STATIC_ASSERT(( Width > 0 ));
- // precondition 4.
+ // precondition 3.
+ BOOST_STATIC_ASSERT(( is_integral<T>::value ));
+};
+
+
+/** The following preconditions apply to the integral_mask type.
+ * Preconditions
+ *
+ * 1. T must be an integral type.
+ *
+ * 2. Value must be in the domain of the integral type T.
+ *
+ */
+template <typename T, T Value>
+struct integral_mask_preconditions {
+ // precondition 1.
BOOST_STATIC_ASSERT(( is_integral<T>::value ));
+
+ // precondition 2.
+ BOOST_STATIC_ASSERT((std::numeric_limits<T>::max >= Value ));
+ BOOST_STATIC_ASSERT((std::numeric_limits<T>::min <= Value ));
};
+
} // end of details namespace.
} // end of boost namespace.
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